jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.06k stars 215 forks source link

Invoke callbacks asynchronously #252

Closed corhere closed 5 years ago

corhere commented 5 years ago

The BrowserFS FileSystem interface documents several assumptions about arguments passed to API implementations. Notably, it is documented that callbacks will reset the stack depth using setImmediate. https://github.com/jvilk/BrowserFS/blob/28a26cbcb89b5cef59a586f55045aabe98561f47/src/core/file_system.ts#L57-L59

This assumption originally held true, but the implementation was removed for release builds in #139. This change broke code that relied upon callbacks being asynchronous, including glob-stream, when using synchronous filesystem backends. Reintroduce the callback wrapping behaviour so that the assumption holds true once again.

jvilk commented 5 years ago

I was wondering if that optimization would break code in the wild. Thanks for letting me know. I'll merge this in.