Synchronously Call Your Asynchronous Functions!
summary
Babel migrates to ESM so dynamic import forces async plugin loading, but synchronous APIs like babel-register and the parser must keep working; solution uses Node worker threads with a SharedArrayBuffer, Atomics.wait/notify and MessageChannel: main thread blocks on Atomics.wait, worker does async work, serializes result or error back, Atomics.notify wakes the main thread, which returns the value. Production requires try/catch everywhere and notify in finally. Works in Node (recent Node internals use it), not usable on the browser main thread.
AI-written summary · about
chapters (7)
- 0:00Introduction
- 1:02Why sync async functions
- 2:52Worker threads and atomics
- 6:41Error handling in threads
- 8:30Browser limitations
- 9:12Real-world use cases
- 10:14Conclusion and Q&A
related talks
36mMigrating Babel from CommonJS to ESM
14mThe Promised Path to Async, Awaits
33mAsync patterns to scale your multicore JavaScript elegantly.
42mBeyond Promises: Async Patterns in JavaScript
46mThe journeyman’s guide to modules in Node.js
25mECMAScript of the Future: ES2017 & Beyond
33mAsync Programming in ES7
22mPlease wait... loading: a tale of two loaders
