Friday 28 June 2019

Question about synchronous functions and blocking behavior

Hi Everyone,I'm using express for a little web api and I was wondering how exactly a synchronous operation would block the node process.Let's take that simple code :const express = require('express') const app = express() app.get('/route1', function (req, res) { res.send('Hello route1!') }) app.get('/route2', function (req, res) { someHeavySyncFunction() //Let's imagine this function is synchronous and take 2 min to complete res.send('Hello route2!') }) app.listen(3000, function () { console.log('Example app listening on port 3000!') }) Would my route2 block the entire node process and therefore preventing people to access my route1 until the function ends ?Thank you

Submitted June 28, 2019 at 02:59PM by wbulot

No comments:

Post a Comment