functions called from browser execute twice
See original GitHub issueAlthough curl will only call the function once. Chrome load or refresh calls the function twice. A bit confusing when debugging something more complex than HelloWorld.
Very easy to see:
exports.helloWorld = (req, res) => {
console.log('running HelloWorld'); // <-- oh no not again
res.send('Hello, World');
};
Is there a way to stop this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (7 by maintainers)
Top Results From Across the Web
functions called from browser execute twice · Issue #33 - GitHub
Chrome load or refresh calls the function twice. A bit confusing when debugging something more complex than HelloWorld. Very easy to see:.
Read more >function is being executed twice when called only once
Your browser is making two requests to your server, most likely one for the URL you put in the address bar and another...
Read more >Content Script Executing Twice? - Mozilla Discourse
js, you execute the script again using browser.tabs.executeScript, which causes the second execution. Nothing wrong with Firefox here.
Read more >QGIS plugin triggers function twice - GIS Stack Exchange
I have a plugin with a function (triggered by a button) that selects a specific layer by name, then shows its attribute table....
Read more >Function called twice javascript
The basic idea is to set a timeout to call the function after a certain time (half second here, depends on the execution...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

OK so we think this is happening because browser requests also send a request for a favicon. This means that hitting the function in the browser results in two invocations of the function.
I think we can fix this by changing our logic to only invoke the function in response to requests on
/${function_name}instead of/*.Thanks for the report.
Hello, I have the same problem, but I do not understand the answers speaking the link with favicon: in the second call, I find in “req.url” the same path as in the first call. This bug becomes annoying as soon as I dedug the Node server, because I’m juggling between 2 threads which do the same things in parallel.
Does anyone know how to block this in Chrome?