fix(ts-sdk): emit v0 root-import deprecation via process.emitWarning#3933
Open
sushaan-k wants to merge 1 commit into
Open
fix(ts-sdk): emit v0 root-import deprecation via process.emitWarning#3933sushaan-k wants to merge 1 commit into
sushaan-k wants to merge 1 commit into
Conversation
The root export of `@hatchet-dev/typescript-sdk` printed seven red
`console.warn` lines at module evaluation time because `index.ts`
re-exports both `./workflow` and `./step`, and each submodule fired
several raw `console.warn` calls.
Because the warnings were raw `console.warn`:
* They could not be suppressed via Node's standard flags
(`--no-deprecation`, `--no-warnings`,
`--no-warnings=DeprecationWarning`).
* They did not carry a stable `code`, so users could not filter
them in `process.on('warning', ...)` handlers.
* They were duplicated whenever both submodules were loaded.
Introduce a small `emitV0RemovedWarning` helper that emits a single
`DeprecationWarning` via `process.emitWarning` with the stable code
`HATCHET_V0_REMOVED`, deduplicating per submodule. The migration nag
remains visible by default but now respects Node's deprecation surface.
Falls back to `console.warn` only when the host runtime does not expose
`process.emitWarning`.
Closes hatchet-dev#3915
|
@sushaan-k is attempting to deploy a commit to the Hatchet Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the TypeScript SDK’s root-import v0 deprecation messaging to use Node’s standard warning mechanism (process.emitWarning) so consumers can suppress/dedupe/filter warnings using built-in Node flags and warning handlers.
Changes:
- Introduces a
emitV0RemovedWarning(submodule, detail?)helper that emitsDeprecationWarningwith codeHATCHET_V0_REMOVED(with aconsole.warnfallback). - Replaces the module-evaluation
console.warnblocks inworkflow.tsandstep.tswith a single helper call each. - Adds unit tests covering the warning shape, code, per-submodule dedupe, and fallback behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdks/typescript/src/workflow.ts | Replaces v0 root-import console.warn banner with a single structured deprecation warning emission. |
| sdks/typescript/src/step.ts | Replaces v0 root-import console.warn banner with a single structured deprecation warning emission. |
| sdks/typescript/src/util/v0-deprecation-warning.ts | Adds centralized warning emission + per-submodule dedupe and fallback logic. |
| sdks/typescript/src/util/v0-deprecation-warning.test.ts | Adds Jest coverage for emission, code, dedupe, and fallback paths. |
Comment on lines
+24
to
+25
| /** Reset hook for tests — not part of the public API. */ | ||
| export function _resetEmittedV0Warnings(): void { |
| * anyone importing from the root, since `index.ts` re-exports both). | ||
| * | ||
| * Switching to `process.emitWarning` with a fixed code makes the warnings | ||
| * filterable, dedupable, and consistent with the rest of Node's deprecation |
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.
What does this PR do?
Replaces the seven raw
console.warncalls that fire on import of@hatchet-dev/typescript-sdkwithprocess.emitWarning(..., { type: 'DeprecationWarning', code: 'HATCHET_V0_REMOVED' }). The migration nag is still visible by default, but is now suppressible via Node's standard flags, deduplicated, and carries a stable code that consumers can filter on inprocess.on('warning', ...)handlers.Why?
Importing the root specifier currently prints seven red
console.warnlines on every process start becauseindex.tsre-exports both./workflowand./step, and each submodule fires several rawconsole.warns at module evaluation. Those messages:--no-deprecation,--no-warnings,--no-warnings=DeprecationWarninghave no effect.code—process.on('warning', …)handlers have nothing stable to match on.This is friction every consumer of the root import hits today, including the v1 setup guide's documented entry point.
Changes
sdks/typescript/src/util/v0-deprecation-warning.tsexportsemitV0RemovedWarning(submodule, detail?)and the stableV0_DEPRECATION_CODE = 'HATCHET_V0_REMOVED'. Falls back toconsole.warnonly when the host runtime does not exposeprocess.emitWarning.sdks/typescript/src/workflow.tsandsdks/typescript/src/step.tsreplace theirconsole.warnblocks with oneemitV0RemovedWarning(...)call each.sdks/typescript/src/util/v0-deprecation-warning.test.tscovers theemitWarningshape, thecode, per-submodule dedupe, separate warnings for distinct submodules, and theconsole.warnfallback path.Testing
```sh
cd sdks/typescript
pnpm exec jest src/util/ # 5 suites, 16 passed, 2 skipped — no regressions, new helper suite green
pnpm lint:check # clean
pnpm exec tsc # clean
```
Smoke-tested against Node 24:
```sh
Suppression flags now actually work
node --no-deprecation --require ts-node/register -e "require('./src/util/v0-deprecation-warning.ts').emitV0RemovedWarning('workflow')"
node --no-warnings=DeprecationWarning --require ts-node/register -e "require('./src/util/v0-deprecation-warning.ts').emitV0RemovedWarning('workflow')"
process.on('warning') receives a structured warning with .code === 'HATCHET_V0_REMOVED'
```
Notes for maintainers
HATCHET_V0_REMOVEDcode shape suggested in the issue to make review easier. Happy to switch to per-submodule codes (HATCHET_V0_WORKFLOW_REMOVED,HATCHET_V0_STEP_REMOVED) if you'd prefer finer-grained suppression.emitDeprecationNoticehelper underv1/client/worker/deprecated/deprecation.tswas considered, but it requires aLoggerinstance —workflow.tsandstep.tsfire at module-evaluation time with no logger context, and the issue's preferred shape wasprocess.emitWarninganyway.Closes #3915