JavaScript event loop does NOT "run to completion" - Stack Overflow
According to MDN, messages in the JavaScript event loop "run to completion".
()
But I have created a case where this does not seem to happen.
abortController1 = new AbortController()
abortController2 = new AbortController()
abortController1.signal.addEventListener("abort", () =>
{
console.log("abort 1 start")
abortController2.abort()
console.log("abort 1 end")
})
abortController2.signal.addEventListener("abort", () =>
{
console.log("abort 2")
})
abortController1.abort()
According to MDN, messages in the JavaScript event loop "run to completion".
(https://developer.mozilla.org/docs/Web/JavaScript/Event_loop#run-to-completion)
But I have created a case where this does not seem to happen.
abortController1 = new AbortController()
abortController2 = new AbortController()
abortController1.signal.addEventListener("abort", () =>
{
console.log("abort 1 start")
abortController2.abort()
console.log("abort 1 end")
})
abortController2.signal.addEventListener("abort", () =>
{
console.log("abort 2")
})
abortController1.abort()
Output:
abort 1 start
abort 2
abort 1 end
I was expecting to see this output:
abort 1 start
abort 1 end
abort 2
Can someone please explain what's going on here?
Share Improve this question asked 18 hours ago olfekolfek 3,5024 gold badges37 silver badges54 bronze badges 2
最新文章
- 千万别反悔 库克称苹果不会推出变形本
- Windows 10硬件产品发布会汇总 微软喊你换电脑
- 探秘2012台北国际电脑展(图)
- oauth - SSO to 3rd party through AzureAD - Stack Overflow
- python - Arcpy seems to not carry out my SQL clause - Stack Overflow
- javascript - Submit in .jsp file not 'seeing' dijit.byid tabs in associated Dojo.js file - Stack Overflow
- reactjs - Next.js - I need static error page template in non-static app router based app - Stack Overflow
- amazon web services - Why is my AWS CDK Stack failing for an unclear reason? - Stack Overflow
- home assistant - Putting sensors in separate YAML file leads to errors - Stack Overflow
- python - Pyinstaller (Mac App) - Why only permission given to the executable file (instead of .app bundle) could work? - Stack O
- reactjs - can not use an id that I saved in props as default value in react select - Stack Overflow
- How to log information in Spring application when request is received and before response is returned - Stack Overflow
- spring boot - Java - Implement @Component class dynmically - Stack Overflow
- r - Why does adding markers in a Shiny app work for one map but not the other? - Stack Overflow
- React native - OCR of price tag - Stack Overflow
- sql - How to validate data is Hexadecimal in Presto - Stack Overflow
- php - Laravel Defer on API requests - Stack Overflow
abort()
, that listener is called synchronously within the current event loop. – Barmar Commented 18 hours ago