Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWS: Async rewrite #8887

Closed
wants to merge 315 commits into from
Closed

MWS: Async rewrite #8887

wants to merge 315 commits into from

Conversation

Arlen22
Copy link
Contributor

@Arlen22 Arlen22 commented Jan 9, 2025

It was kind of fun. This took me about 12 hours, not counting interruptions.

It's not much of a rewrite, more just converting every database call (and everything upstream of every database call) to async/await.

If you haven't used VSCode, you're definitely going to want to explore the code using it to fully appreciate the little improvements that typing can bring.

I'm still working out a few bugs surrounding the somewhat confusing authenticatedUser property. But I'm too tired and I need to get some sleep and take a fresh look at it later.

Jermolene and others added 30 commits January 28, 2024 17:11
…rchive

The archive format is a legacy format that I used with Xememex, and will need to be updated to iron out the wrinkles
This is the start of adding support for large attachments.

We have a new endpoint for POSTing tiddler data. The idea is that it will take any kind of data and figure out how to extract tiddlers from the upload and save them in the nominated bag.

The next step is to move the attachment files into a special folder and reference them from the database so that we can construct _canonical_uris for them.
To make us more tolerant of proxies that "helpfully" decodeuricomponent for us (looking at you Azure)
)

* Use transactions when modifying multiple resources

This prevents partial changes from entering the database, and also
nets a nice speed-up.

* Keep track of transaction depth

…so we could someday potentially leverage SQL implementations that don't
implement nested transactions
…yWiki#7996)

* Switch from better-sqlite3 to node-sqlite3-wasm

Seems to be slower, but might make cloud deployments easier by not having any binary dependencies

* More logging

* Temporarily use a memory database

We will make this configurable

* Revert "More logging"

* Resume loading demo tiddlers

* Cache prepared statements

Gives a 20% reduction in startup time on my machine

* Some more logging

* Update package-lock

* More logging

* Route regexps should allow for proxies that automatically decode URLs

Astonishingly, Azure does this

* Go back to a file-based database

* Less logging

* Update package-lock.json

* Simplify startup by not loading the docs edition

* Tiddler database layer should mark statements as having been removed

* Re-introduce better-sqlite3

* Make the SQLite provider be switchable

* Support switchable SQL engines

I am not intending to make this a long term feature. We will choose one engine and stick with it until we choose to change to another.

* Adjust dependency versions

* Setting up default engine

* Make transaction handling compatible with node-sqlite3-wasm

https://github.com/tndrle/node-sqlite3-wasm doesn't have transaction support so I've tried to implement it using SQL statements directly.

@hoelzro do you think this is right? Should we be rolling back the transaction in the finally clause? It would be nice to have tests in this area...

I looked at better-sqlite3's implementation - https://github.com/WiseLibs/better-sqlite3/blob/master/lib/methods/transaction.js

* Default to better-sqlite3 for compatibility after merging
It appears that not all statements can be finalized.
@linonetwo the resulting archive should be suitable for storing in git
Jermolene and others added 27 commits December 9, 2024 17:51
I think this was introduced in TiddlyWiki#8455 sorry it took me so long to notice
* TiddlyWiki#8812 resolve issue with anonymous access

* TiddlyWiki#8812 bug fix with anonymous access
Available in Node.js 22.50 - see https://nodejs.org/api/sqlite.html

Given the Node.js release timeline, I think it will be reasonable to switch to the integrated Node.js sqlite as the default, which will avoid all the npm install kerfuffle too.
Copy link

github-actions bot commented Jan 9, 2025

Confirmed: Arlen22 has already signed the Contributor License Agreement (see contributing.md)

@Arlen22 Arlen22 closed this Jan 9, 2025
Copy link

netlify bot commented Jan 9, 2025

Deploy Preview for tiddlywiki-previews failed.

Name Link
🔨 Latest commit 14c7c36
🔍 Latest deploy log https://app.netlify.com/sites/tiddlywiki-previews/deploys/677f9bb2c1805e00087b9b72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants