Comments (3)
This is a good idea, but it would probably require some abstraction busting since the file system layer doesn't know anything about which query it is currently answering.. Otherwise it would be possible by sending a cancellation signal from the main thread, but that would probably require SharedArrayBuffer for signalling since everything in the worker thread happens synchronously. Adding a dependency to SharedArrayBuffer isn't great since it's not supported in many cases.
from sql.js-httpvfs.
I'm happy to bust some abstractions!
https://github.com/bakkot/sql.js-httpvfs#a-fork-of-sqljs-httpvfs-which-bounds-the-number-of-requests
(See this commit. It's just overriding XMLHttpRequest.prototype.send
in the worker so that it throws once the bound is reached.)
I imagine this is too gross to include in the actual repo (especially since it seems to put the database into an unrecoverable state - as would a network error, from what I can tell?), so I haven't PR'd it, but it does work. Happy to send a PR if you'd like, though.
from sql.js-httpvfs.
I think the reason error throws "corrupt" the database is since emscripten doesn't handle exceptions at all by default, leaving SQLite in an undefined state. You should be able to avoid that by returning an I/O error instead. That should be possible with something similar to throw FS.ErrnoError(FS.ERRNO_CODES.EIO)
. Probably you should even be able to throw EAGAIN
(see sqliteErrorFromPosixError in https://www.sqlite.org/src/doc/trunk/src/os_unix.c) then it should report it as "Database is busy" instead of "database is corrupted".
As an aside you don't need to add your own event handler to the worker etc, you can add your functions to const mod = {
and they will be automatically proxied by comlink. Passing functions works with fn(Comlink.proxy(callback))
. The http request thing should probably also be added to the doXHR function of lazyfile instead of modifying the prototype, and of course reset the counter when the error is thrown.
If all that works cleanly, I think this would be a good addition to the library itself
from sql.js-httpvfs.
Related Issues (20)
- Support for Sharding? HOT 4
- Out of memory errors? HOT 4
- Server crashes on starting HOT 2
- webpack cannot bundle the worker
- New NPM release and/or build instructions? HOT 2
- Possible serverChunkSize un-awareness of lazyFile's speedup system incompatible with rangemapper db chunking. HOT 3
- Does this vfs support update, delete and insert? HOT 1
- Can't create JS function with create_function()
- Advice on speeding up initial load of a table HOT 1
- [not an issue] Questions on how the plugin works and how to speed up initial worker load HOT 7
- concurrent access HOT 6
- Failing to init WASM with Node.js / Web Worker polyfill / type: `module` HOT 2
- Not compatible with Node.js 16+ HOT 1
- Document workaround for slow HEAD
- Throw an error if server ignores RANGE header
- Any way to optimize this recursive query? HOT 2
- Firefox issue with virtual tables (gitlab pages sqlite.db file hosting) HOT 2
- Fix broken build due to invalid dep graph HOT 2
- Can't import createDbWorker in Javascript ?
- [Showcase] Using it to show how Toki Pona has grown and changed as a language!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sql.js-httpvfs.