Skip to content

fix(ts-sdk): emit v0 root-import deprecation via process.emitWarning#3933

Open
sushaan-k wants to merge 1 commit into
hatchet-dev:mainfrom
sushaan-k:aarya/v0-deprecation-emit-warning
Open

fix(ts-sdk): emit v0 root-import deprecation via process.emitWarning#3933
sushaan-k wants to merge 1 commit into
hatchet-dev:mainfrom
sushaan-k:aarya/v0-deprecation-emit-warning

Conversation

@sushaan-k
Copy link
Copy Markdown

What does this PR do?

Replaces the seven raw console.warn calls that fire on import of @hatchet-dev/typescript-sdk with process.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 in process.on('warning', ...) handlers.

Why?

Importing the root specifier currently prints seven red console.warn lines on every process start because index.ts re-exports both ./workflow and ./step, and each submodule fires several raw console.warns at module evaluation. Those messages:

  1. Cannot be filtered--no-deprecation, --no-warnings, --no-warnings=DeprecationWarning have no effect.
  2. Are not deduplicated — both submodules print near-identical banners on every boot.
  3. Have no codeprocess.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

  • New sdks/typescript/src/util/v0-deprecation-warning.ts exports emitV0RemovedWarning(submodule, detail?) and the stable V0_DEPRECATION_CODE = 'HATCHET_V0_REMOVED'. Falls back to console.warn only when the host runtime does not expose process.emitWarning.
  • sdks/typescript/src/workflow.ts and sdks/typescript/src/step.ts replace their console.warn blocks with one emitV0RemovedWarning(...) call each.
  • New sdks/typescript/src/util/v0-deprecation-warning.test.ts covers the emitWarning shape, the code, per-submodule dedupe, separate warnings for distinct submodules, and the console.warn fallback 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

  • I matched the exact HATCHET_V0_REMOVED code 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.
  • The existing emitDeprecationNotice helper under v1/client/worker/deprecated/deprecation.ts was considered, but it requires a Logger instance — workflow.ts and step.ts fire at module-evaluation time with no logger context, and the issue's preferred shape was process.emitWarning anyway.

Closes #3915

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
Copilot AI review requested due to automatic review settings May 18, 2026 03:14
@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

@sushaan-k is attempting to deploy a commit to the Hatchet Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 emits DeprecationWarning with code HATCHET_V0_REMOVED (with a console.warn fallback).
  • Replaces the module-evaluation console.warn blocks in workflow.ts and step.ts with 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
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.

Deprecation warnings on root import are unfilterable (console.warn instead of process.emitWarning)

2 participants