Skip to content

fix: fail dts builds when the worker dies without a result - #1414

Open
cpruijsen wants to merge 1 commit into
egoist:mainfrom
cpruijsen:fix/issue-1410
Open

fix: fail dts builds when the worker dies without a result#1414
cpruijsen wants to merge 1 commit into
egoist:mainfrom
cpruijsen:fix/issue-1410

Conversation

@cpruijsen

Copy link
Copy Markdown

Summary

--dts listens for 'error' and 'exit' on the dts worker and rejects with dts build worker exited with code ${code} without reporting a result. A DTS pass that produced nothing now fails the build.

The parent promise used to settle only on worker 'message' ('success' / 'error'). If the worker died without posting a result, that promise stayed pending, the event loop drained, and tsup exited 0 with JS in dist/ and no .d.ts files. Build caches then stored that artifact as a success; consumers later saw TS7016.

Closes #1410

Decision

Both 'error' and 'exit' handlers, reject(new Error(...)), no settled flag. Alternative: PrettyError (message-only CLI output) and/or a boolean so 'exit' after terminate() is ignored explicitly.

This is the patch the issue verified on 8.5.1, and it matches the existing dts-worker failure reject(new Error('error occurred in dts build')). Rejecting an already-resolved promise is a no-op; existing --dts tests still pass. Can switch to PrettyError or a settled guard.

Test plan

  • vitest run test/dts.test.ts -t "dts worker exiting without a result" fails without the handlers (exit 0, no .d.ts), passes with them (exit 1, error names the worker)
  • vitest run test/dts.test.ts all 13 dts tests pass (healthy declaration emit unchanged)
  • vitest run 96 tests passed locally (Node 26, darwin)
  • CI: ubuntu + windows, Node 18/20/22

Otherwise tsup exits 0 with a declaration-less dist/, which caches as a successful build.
@codesandbox

codesandbox Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

@cpruijsen is attempting to deploy a commit to the EGOIST's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

dts build: a worker that dies without posting a message leaves the build promise pending — tsup exits 0 having emitted no declarations

1 participant