Add Workflow Types to workers-types
ref https://github.com/getsentry/sentry-javascript/pull/16704
The following types:
WorkflowEntrypoint,
WorkflowEvent,
WorkflowSleepDuration,
WorkflowStep,
WorkflowStepConfig,
WorkflowStepEvent,
WorkflowTimeoutDuration,
are not available via @cloudflare/workers-types (tested with 4.20250620.0). The Sentry Cloudflare SDK needs them for our upcoming Cloudflare Workflows instrumentation. It would be great if they got exposed!
The Sentry SDK ended up vendoring them in, but this will cause problems as the types get updated.
Hi, perhaps i'm misunderstanding you, but it looks like these types are available? https://github.com/cloudflare/workerd/blob/main/types/generated-snapshot/latest/index.d.ts#L7999 https://github.com/cloudflare/workerd/blob/main/types/generated-snapshot/latest/index.d.ts#L7969 etc.
(these snapshots match what is published as workers-types)
I apologize if I'm misunderstanding something, but when I tried to import this from the package I couldn't access WorkflowStep: https://stackblitz.com/edit/vitejs-vite-lobp6cn4?file=src%2Fmain.ts
So WorkflowStep is actually a native abstract class exported from workerd.
It's available by importing from "cloudflare:workers".
To ensure that "virtual module" is available in your code you need to add @cloudflare/workers-types to the tsconfig.
So to in your code you can use:
import type { WorkflowStep } from "cloudflare:workers";
let x: WorkflowStep;
and in your tsconfig.json you need:
{
"compilerOptions": {
// ...
"types": [
"@cloudflare/workers-types"
]
}
}
I'm building a library that vendors in these types: https://github.com/getsentry/sentry-javascript/tree/develop/packages/cloudflare
importing from cloudflare:workers is breaking some user setups (https://github.com/getsentry/sentry-javascript/issues/16099) so I'm trying to move off of that to explicitly always import from @cloudflare/workers-types.
I would much prefer if we can avoid the virtual module for cloudflare library development.
Hi. Are you able to share exactly what the issue is that this causes so that we can see if there's some way we could fix? As some of these types are classes used at runtime, they need to be importable from cloudflare:workers.
https://github.com/getsentry/sentry-javascript/issues/16099 is the tracking issue for this problem, there are also multiple reproductions provided there.
As some of these types are classes used at runtime
Ideally I want full type safety for a method like https://github.com/getsentry/sentry-javascript/blob/12528ec04ce752db6e800f2d577c3d7fcda3d24b/packages/cloudflare/src/workflows.ts#L171
I want to make sure that users pass the right arguments to the wrapping function, and that the wrapping function returns the right value back.
is this missing the awaiting Cloudflare response label?
cc @jamesopstad @petebacondarwin