|
1 | | -# Progress Log |
2 | | - |
3 | | -## 2026-04-21: |
| 1 | +# Progress |
| 2 | + |
| 3 | +### Fixed: async hook stack corruption on macOS CI |
| 4 | +- **Status**: Root cause not yet definitively identified. HandleScope fix is next hypothesis to test. |
| 5 | +- Original error: `Error: async hook stack has become corrupted (actual: 573357, expected: 573357)` |
| 6 | +- Extensive static analysis of Node.js source code completed |
| 7 | +- Key finding: `napi_delete_async_work` from within complete callback is the documented correct pattern |
| 8 | +- Key finding: `EmitAsyncDestroy` is DEFERRED (via SetImmediate), does NOT pop async context |
| 9 | +- Key finding: `CallbackScope` copies `async_context_` by value, so Work deletion doesn't affect values |
| 10 | +- Key finding: `actual == expected` pattern (same integer displayed with `%.f`) suggests non-integer doubles or race condition |
| 11 | +- Key finding: Only crashes on macOS x64 (never on Linux x64 or macOS arm64) |
| 12 | +- Key finding: HandleScope accumulation — each `CREATE_WORK` call inside a complete callback creates `Local<>` handles that accumulate in the outer `HandleScope` |
| 13 | +- Added `SQLITE3_DEBUG_ASYNC_HOOKS=1` env var for diagnostic logging in stress test |
| 14 | +- Added macOS debug step in CI workflow |
| 15 | +- **Next steps**: Try HandleScope fix, reorder CI steps, file Node.js bug report if needed |
4 | 16 |
|
5 | 17 | ### SQLite Build Pipeline using sqlite-amalgamation-*.zip |
6 | | -- Switched from `sqlite-autoconf-*.tar.gz` (extracted at build time) to `sqlite-amalgamation-*.zip` (pre-extracted in `deps/`) |
7 | | -- Removed `tar` npm dependency from `package.json` |
8 | | -- Removed `deps/extract.js` (no longer needed) |
9 | | -- Updated `deps/sqlite3.gyp` — removed `action_before_build` target, paths now reference local sqlite-amalgamation-* dir |
10 | | -- Updated `tools/bin/bump-sqlite.sh` — downloads amalgamation zip, extracts immediately, commits directory |
11 | | -- All 277 tests pass, build verified |
| 18 | +- Switched from `sqlite-autoconf-*.tar.gz` to `sqlite-amalgamation-*.zip` |
| 19 | +- Removed `tar` npm dependency |
| 20 | +- Simplified `deps/sqlite3.gyp` (no `action_before_build`) |
| 21 | +- Updated `tools/bin/bump-sqlite.sh` |
12 | 22 |
|
13 | 23 | ### ESM + CJS Dual Support Implementation |
14 | | -- Implemented ESM wrapper pattern using native CJS→ESM interop in `.mjs` entry points |
15 | | -- Created `lib/sqlite3.mjs` — ESM entry point for main module (default + named exports) |
16 | | -- Created `lib/promise/index.mjs` — ESM entry point for promise subpath |
17 | | -- Created `lib/promise/index.d.ts` — TypeScript declarations for promise subpath |
18 | | -- Created `lib/sqlite3-callback.js` — Extracted callback API from sqlite3.js to break circular dependency |
19 | | -- Modified `lib/sqlite3.js` — Now a thin wrapper that re-exports callback API and adds promise classes |
20 | | -- Modified `lib/promise/database.js` — Changed to require `sqlite3-callback.js` instead of `sqlite3.js` |
21 | | -- Modified `lib/sqlite3.d.ts` — Added `export default sqlite3;` |
22 | | -- Modified `package.json` — Added conditional `exports` map, updated `files` and `test` script |
23 | | -- Modified `eslint.config.mjs` — Added `.mjs` file patterns |
24 | | -- Created `test/esm.test.mjs` — 38 ESM-specific tests |
25 | | -- Updated `.github/workflows/test-npm-package.yml` — Added `workflow_call` trigger, ESM smoke tests |
26 | | -- Updated `.github/workflows/ci.yml` — Added `test-package` job calling reusable workflow |
27 | | -- Updated `README.md` and `docs/API.md` — ESM usage documentation |
28 | | - |
29 | | -## 2026-04-17: |
| 24 | +- CJS: `lib/sqlite3.js` → `lib/sqlite3-callback.js` + `lib/sqlite3-binding.js` |
| 25 | +- ESM: `lib/sqlite3.mjs` → `lib/promise/` (SqliteDatabase, SqliteStatement, SqliteBackup) |
| 26 | +- TypeScript definitions updated |
| 27 | +- All 281 tests passing (including ESM tests) |
30 | 28 |
|
31 | 29 | ### SQLite Version Bump Script |
32 | | -- Created [`tools/bin/bump-sqlite.sh`](../tools/bin/bump-sqlite.sh) — automated 17-step script for upgrading bundled SQLite |
33 | | -- Features: auto-detect latest version from sqlite.org, cooldown period check, checksum verification, dry-run mode |
34 | | -- Bugs fixed during real-world testing: |
35 | | - - `git rm` / `git rm -r` for old amalgamation dir (stages deletion for commit) |
36 | | - - `${tmp_dir:-}` in EXIT trap to avoid unbound variable error |
37 | | - - `FROM_VERSION` global variable to preserve original version for commit message (gypi file already updated by step 10) |
38 | | - |
39 | | -## 2026-04-10: |
40 | | - |
41 | | -### v6.3.0 |
| 30 | +- `tools/bin/bump-sqlite.sh` downloads amalgamation zip, extracts, commits |
| 31 | +- Version driven by `sqlite_version` in `deps/common-sqlite.gypi` |
42 | 32 |
|
43 | 33 | ### fixed: queue processing deadlock in serialized mode |
44 | | - - Fixed bug where operations get stuck in queue when using `db.serialize()` with synchronous operations |
45 | | - - Issue: https://github.com/TryGhost/node-sqlite3/issues/1838 |
46 | | - - Modified `Database::Process()` in `src/database.cc` to detect synchronous operations |
47 | | - - Added test cases in `test/serialization.test.js` |
48 | | - - Solution: Track `pending` counter before/after callback to detect synchronous completion |
49 | | - |
50 | | -## 2026-04-04: |
51 | | - |
52 | | -### fixed: potential crash during shutdown |
53 | | - please see [microsoft/vscode-node-sqlite3/issues/67](https://github.com/microsoft/vscode-node-sqlite3/issues/67) |
54 | | - |
55 | | -## 2026-03-29 |
| 34 | +- Database::Process() now tracks `pending` counter before/after callback |
| 35 | +- If `pending` unchanged and `locked` is true, operation was synchronous → reset `locked` and continue |
| 36 | +- This prevents the queue from stalling when a synchronous operation (like `db.run()`) is queued in serialized mode |
56 | 37 |
|
57 | 38 | ### Security Hardening Documentation |
58 | | -- Added comprehensive security hardening section to `build-system.md` |
59 | | -- Documented Linux hardening flags: `-fstack-protector-strong`, `-fPIC`, RELRO, `_FORTIFY_SOURCE=2`, CET |
60 | | -- Documented Windows hardening: BufferSecurityCheck, ControlFlowGuard, ASLR, DEP, /sdl |
61 | | -- Documented macOS hardening: `-fstack-protector-strong`, libc++ |
62 | | -- Added hardening decision entry to `decisionLog.md` |
63 | | -- Created hardening summary table comparing all platforms |
| 39 | +- Documented hardening flags in `memory-bank/build-system.md` |
| 40 | +- Linux: RELRO, stack protector, FORTIFY_SOURCE, PIE, -fno-omit-frame-pointer |
| 41 | +- macOS: PIE, hardened runtime |
| 42 | +- Windows: CFG, CET compat |
64 | 43 |
|
65 | | -### Memory Bank Update |
66 | | -- Removed `NAPI_DISABLE_CPP_EXCEPTIONS` from documentation (commit 48e95e8a0d32277449c269b41fba6419acb21418) |
67 | | -- Updated `build-system.md` and `project-overview.md` to reflect current binding.gyp configuration |
| 44 | +### NAPI Exception Handling |
| 45 | +- `TRY_CATCH_CALL` macro handles `Napi::Error` exceptions from `napi_call_function` |
| 46 | +- During Node.js/Electron shutdown, `g_env_shutting_down` flag prevents re-throwing exceptions |
68 | 47 |
|
69 | | -## 2026-03-28 |
| 48 | +### Memory Bank Update |
| 49 | +- Updated project-overview.md, build-system.md, decisionLog.md, progress.md |
70 | 50 |
|
71 | 51 | ### Memory Bank Setup |
72 | | -- Created UMB-compliant memory-bank structure |
73 | | -- Added `activeContext.md` for current work tracking |
74 | | -- Added `progress.md` for completed work history |
75 | | -- Added `decisionLog.md` for technical decisions |
76 | | -- Updated to reflect actual project state |
| 52 | +- Created initial memory bank files |
77 | 53 |
|
78 | 54 | ### Promisification Implementation (VERIFIED COMPLETE) |
79 | | -- Promise-based wrapper classes implemented in [`lib/promise/`](../lib/promise/) |
80 | | -- `SqliteDatabase` class with full API coverage |
81 | | -- `SqliteStatement` class with all methods |
82 | | -- `SqliteBackup` class for backup operations |
83 | | -- Transaction support: `beginTransaction()`, `commitTransaction()`, `rollbackTransaction()` |
84 | | -- Static factory method `SqliteDatabase.open()` |
85 | | -- Tests in [`test/promise.test.js`](../test/promise.test.js) |
86 | | - |
87 | | -## v6.2.0 |
88 | | - |
89 | | -### feature: added hardening flags |
90 | | - |
91 | | -### fixed: exception handling |
92 | | - please see [microsoft/vscode-node-sqlite3/pull/47](https://github.com/microsoft/vscode-node-sqlite3/pull/47) |
93 | | - |
94 | | -## v6.1.1 |
95 | | - |
96 | | -### fixed: undefined behavior |
97 | | - please see [TryGhost/node-sqlite3/issues/1827](https://github.com/TryGhost/node-sqlite3/issues/1827) |
98 | | - |
99 | | -## 2026-03-20 |
100 | | - |
101 | | -### v6.1.0 |
102 | | - |
103 | | -### fixed: replace withdrawn SQLite 3.52.0 with stable 3.51.3 |
104 | | - please see [TryGhost/node-sqlite3/pull/1858](https://github.com/TryGhost/node-sqlite3/pull/1858) |
105 | | - |
106 | | -## Earlier Sessions |
| 55 | +- `lib/promise/database.js` - SqliteDatabase class with all async methods returning Promises |
| 56 | +- `lib/promise/statement.js` - SqliteStatement class with all async methods returning Promises |
| 57 | +- `lib/promise/backup.js` - SqliteBackup class with step/finish returning Promises |
| 58 | +- `lib/promise/index.js` - CommonJS entry point |
| 59 | +- `lib/promise/index.mjs` - ESM entry point |
| 60 | +- `lib/promise/index.d.ts` - TypeScript declarations |
| 61 | +- All promise tests passing |
107 | 62 |
|
108 | 63 | ### Project Setup |
109 | | -- Established Node.js >= 20.17.0 requirement |
110 | | -- Configured yarn package manager |
111 | | -- Set up ESLint with `.eslintrc.js` |
112 | | -- Configured node-gyp build system |
| 64 | +- Initial project structure and configuration |
113 | 65 |
|
114 | 66 | ### Build System |
115 | | -- Configured Debug and Release builds |
116 | | -- Set up prebuild for binary distribution |
117 | | -- Enabled SQLite extensions: FTS3/4/5, R-Tree, math functions |
| 67 | +- node-gyp based build with prebuildify |
| 68 | +- SQLite amalgamation downloaded and extracted at build time |
118 | 69 |
|
119 | 70 | ### Testing Infrastructure |
120 | | -- Set up mocha test framework |
121 | | -- Created test support utilities |
122 | | -- Established test database creation pattern |
| 71 | +- Mocha test framework with nyc coverage |
| 72 | +- 281 tests passing (including ESM tests) |
0 commit comments