You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/core/src/workflow.ts
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,30 @@ export async function runWorkflow(
127
127
);
128
128
};
129
129
130
+
// Override timeout/interval functions to throw helpful errors
131
+
// These are not supported in workflow functions because they rely on
132
+
// asynchronous scheduling which breaks deterministic replay
133
+
consttimeoutErrorMessage=`Timeout functions like "setTimeout" and "setInterval" are not supported in workflow functions. Use the "sleep" function from "workflow" for time-based delays.\n\nLearn more: https://useworkflow.dev/err/${ERROR_SLUGS.TIMEOUT_FUNCTIONS_IN_WORKFLOW}`;
134
+
135
+
(vmGlobalThisasany).setTimeout=()=>{
136
+
thrownewvmGlobalThis.Error(timeoutErrorMessage);
137
+
};
138
+
(vmGlobalThisasany).setInterval=()=>{
139
+
thrownewvmGlobalThis.Error(timeoutErrorMessage);
140
+
};
141
+
(vmGlobalThisasany).clearTimeout=()=>{
142
+
thrownewvmGlobalThis.Error(timeoutErrorMessage);
143
+
};
144
+
(vmGlobalThisasany).clearInterval=()=>{
145
+
thrownewvmGlobalThis.Error(timeoutErrorMessage);
146
+
};
147
+
(vmGlobalThisasany).setImmediate=()=>{
148
+
thrownewvmGlobalThis.Error(timeoutErrorMessage);
149
+
};
150
+
(vmGlobalThisasany).clearImmediate=()=>{
151
+
thrownewvmGlobalThis.Error(timeoutErrorMessage);
152
+
};
153
+
130
154
// `Request` and `Response` are special built-in classes that invoke steps
131
155
// for the `json()`, `text()` and `arrayBuffer()` instance methods
0 commit comments