🏗 Replaced remaining dynamic ESM imports with require() - #954
Merged
Conversation
refs #953 Follow-up to the `@tryghost/request` fix. `JobManager` and `WebhookMockReceiver` both loaded `p-wait-for` via `await import()` inside a method, which dates from before Node supported `require()` of ESM. These awaited at the call site rather than caching a module-scope promise, so they never had the wide race window that broke `@tryghost/request` on Node 24. Converting them is cleanup rather than a fix, but it removes the last of the pattern from library code. - Load `p-wait-for` with `require()` at module scope in both packages - Declare the `^22.12.0 || >=24.0.0` engines floor that `require(esm)` needs - Align `got` on 15.1.0 in webhook-mock-receiver to match `@tryghost/request` (test-only dependency there) and drop its `await import('got')` in tests Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reached
On-demand reviews are free for the next 19 days. After that, they cost $0.25 per reviewed file. Or wait 41 minutes for your next included review. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #953.
JobManagerandWebhookMockReceiverboth loadedp-wait-forviaawait import()inside a method — a leftover from before Node supportedrequire()of ESM.Unlike
@tryghost/request, neither had the actual bug: they await at the call site instead of caching a module-scope promise, so the module is never left half-loaded across arbitrary consumer code. The window is just the import's own I/O, and nothing in the repo requiresp-wait-forsynchronously. This is cleanup, not a fix — it removes the last of the pattern from library code.Changes
p-wait-forwithrequire()at module scope injob-managerandwebhook-mock-receiver"engines": { "node": "^22.12.0 || >=24.0.0" }on both, matching 🐛 Fixed dynamic got import race on Node 24 #953 —require(esm)was flagged before 22.12goton 15.1.0 inwebhook-mock-receiverto match@tryghost/request, and drop theawait import('got')in its testsgotis a test-only dependency inwebhook-mock-receiver, so the bump carries no runtime risk. Left it as a literal version rather than moving both packages to acatalog:entry —nx release publishshells out to npm, and I didn't want to bet a published runtime dependency on thecatalog:protocol being rewritten at pack time.Testing
Both suites pass on Node 22 and Node 24: job-manager 40 passed (1 todo), webhook-mock-receiver 8 passed at 100% coverage. Lint and format clean.
🤖 Generated with Claude Code