Skip to content

Fix bin/migrate crash on the fs/promises import - #509

Open
probablyian wants to merge 1 commit into
masterfrom
fix-migrate-fs-import
Open

probablyian wants to merge 1 commit into
masterfrom
fix-migrate-fs-import

Conversation

@probablyian

Copy link
Copy Markdown
Member

Summary

bin/migrate crashes before it connects to the database, so a fresh docker-compose setup never gets its tables. entrypoint.sh tries it 5 times, 10 seconds apart, then starts pulldasher against an empty database.

The ESM conversion in 48b6d14 imported readFileSync from fs/promises, which only has the promise versions, so Node refuses to load the script:

SyntaxError: The requested module 'fs/promises' does not provide an export named 'readFileSync'

This imports it from fs instead. Checked against MySQL 8.4.9 under Node 24: the script exits 0 and creates all 7 tables in migrations/schema.sql, and a second run also exits 0.

QA

  • Point a config at an empty database and run node bin/migrate. Confirm it exits 0.
  • Run SHOW TABLES on that database. Confirm it lists 7 tables.
  • Run node bin/migrate again. Confirm it still exits 0.

https://claude.ai/code/session_01XSa8s7HS2UvFG9Fo9k2oJS

bin/migrate crashes before it connects to the database:

> SyntaxError: The requested module 'fs/promises' does not provide an
> export named 'readFileSync'

The ESM conversion in 48b6d14 swapped the fs.readFile callback for
readFileSync but imported it from fs/promises, which only has the
promise versions (readFile, no readFileSync). Node rejects the named
import while loading the module, so no line of the script runs.

entrypoint.sh runs bin/migrate up to 5 times, 10 seconds apart, then
starts pulldasher anyway, so a fresh docker-compose database never gets
the schema.

Verified against MySQL 8.4.9 under Node 24: the script exits 0 and
creates all 7 tables in migrations/schema.sql, and a second run also
exits 0.

Claude-Session: https://claude.ai/code/session_01XSa8s7HS2UvFG9Fo9k2oJS
@probablyian
probablyian marked this pull request as ready for review October 2, 2026 00:10
@probablyian

Copy link
Copy Markdown
Member Author

QA 🟢

bin/migrate at 3681c77 builds the schema on an empty database and can run again without errors. Master's copy (2da5997) still fails with the error in the PR description. Ran under Node 24.21.0 against a throwaway MySQL 8.4.9.

Check Result Evidence
Master bin/migrate on an empty database fails, exit 1 SyntaxError: The requested module 'fs/promises' does not provide an export named 'readFileSync'
First run on an empty database pass, exit 0 output below
SHOW TABLES pass, 7 tables the same 7 that migrations/schema.sql creates
Second run on the same database pass, exit 0 output below

Tested

  • Point a config at an empty database and run node bin/migrate. Exits 0.
  • Run SHOW TABLES on that database. Lists comments, commit_statuses, issues, pull_labels, pull_signatures, pulls, reviews.
  • Run node bin/migrate again. Still exits 0.

Not tested

  • docker-compose up, which runs the script through entrypoint.sh. The machine this ran on has no Docker.
Command output
$ node bin/migrate        # master 2da5997
import { readFileSync } from 'fs/promises';
         ^^^^^^^^^^^^
SyntaxError: The requested module 'fs/promises' does not provide an export named 'readFileSync'
exit 1

$ node bin/migrate        # 3681c77, empty database
Running this script will initalize your database for pulldasher.
It will not drop any existing tables.
exit 0

mysql> SHOW TABLES;
comments, commit_statuses, issues, pull_labels, pull_signatures, pulls, reviews

$ node bin/migrate        # 3681c77, second run
Running this script will initalize your database for pulldasher.
It will not drop any existing tables.
exit 0

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.

1 participant