Skip to content

Commit 542e5b9

Browse files
committed
revert changes
1 parent 0fd3406 commit 542e5b9

File tree

4 files changed

+35
-74
lines changed

4 files changed

+35
-74
lines changed

packages/workflow/CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# workflow
22

3+
## 4.0.1-beta.6
4+
5+
### Patch Changes
6+
7+
- 70be894: Implement `sleep()` natively into the workflow runtime
8+
- Updated dependencies [796fafd]
9+
- Updated dependencies [796fafd]
10+
- Updated dependencies [70be894]
11+
- Updated dependencies [20d51f0]
12+
- @workflow/core@4.0.1-beta.5
13+
- @workflow/errors@4.0.1-beta.2
14+
- @workflow/cli@4.0.1-beta.6
15+
- @workflow/next@4.0.1-beta.6
16+
- @workflow/nitro@4.0.1-beta.6
17+
- @workflow/typescript-plugin@4.0.1-beta.3
18+
19+
## 4.0.1-beta.5
20+
21+
### Patch Changes
22+
23+
- Updated dependencies [6504e42]
24+
- Updated dependencies [0f845af]
25+
- Updated dependencies [f7862b7]
26+
- Updated dependencies [f2b1619]
27+
- Updated dependencies [08ed58b]
28+
- Updated dependencies [99b4727]
29+
- @workflow/core@4.0.1-beta.4
30+
- @workflow/cli@4.0.1-beta.5
31+
- @workflow/next@4.0.1-beta.5
32+
- @workflow/nitro@4.0.1-beta.5
33+
- @workflow/typescript-plugin@4.0.1-beta.3
34+
335
## 4.0.1-beta.4
436

537
### Patch Changes

packages/workflow/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "workflow",
3-
"version": "4.0.1-beta.4",
3+
"version": "4.0.1-beta.6",
44
"description": "Workflow DevKit - Build durable, resilient, and observable workflows",
55
"main": "dist/index.cjs",
66
"type": "module",
@@ -46,16 +46,13 @@
4646
"typecheck": "tsc --noEmit"
4747
},
4848
"dependencies": {
49-
"@types/bun": "^1.3.1",
5049
"@workflow/bun": "workspace:*",
5150
"@workflow/cli": "workspace:*",
5251
"@workflow/core": "workspace:*",
5352
"@workflow/errors": "workspace:*",
5453
"@workflow/next": "workspace:*",
5554
"@workflow/nitro": "workspace:*",
56-
"@workflow/typescript-plugin": "workspace:*",
57-
"bun": "^1.3.0",
58-
"ms": "2.1.3"
55+
"@workflow/typescript-plugin": "workspace:*"
5956
},
6057
"devDependencies": {
6158
"@types/ms": "^2.1.0",

packages/workflow/src/stdlib.ts

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,10 @@
11
/**
22
* This is the "standard library" of steps that we make available to all workflow users.
3-
* The can be imported like so: `import { sleep, fetch } from 'workflow'`. and used in workflow.
3+
* The can be imported like so: `import { fetch } from 'workflow'`. and used in workflow.
44
* The need to be exported directly in this package and cannot live in `core` to prevent
55
* circular dependencies post-compilation.
66
*/
77

8-
import { RetryableError } from '@workflow/errors';
9-
import ms, { type StringValue } from 'ms';
10-
import { getStepMetadata } from './index.js';
11-
12-
// vqs has a max message visibility lifespan, the workflow sleep function
13-
// will retry repeatedly until the user requested duration is reached.
14-
// (Eventually make this configurable based on the queue backend adapter)
15-
const MAX_SLEEP_DURATION_SECONDS = ms('23h') / 1000;
16-
17-
/**
18-
* Sleep within a workflow for a given duration.
19-
*
20-
* @param duration - The duration to sleep for, this is a string in the format
21-
* of `"1000ms"`, `"1s"`, `"1m"`, `"1h"`, or `"1d"`.
22-
* @overload
23-
* @returns A promise that resolves when the sleep is complete.
24-
*/
25-
export async function sleep(duration: StringValue): Promise<void>;
26-
27-
/**
28-
* Sleep within a workflow until a specific date.
29-
*
30-
* @param date - The date to sleep until, this must be a future date.
31-
* @overload
32-
* @returns A promise that resolves when the sleep is complete.
33-
*/
34-
export async function sleep(date: Date): Promise<void>;
35-
36-
export async function sleep(param: StringValue | Date): Promise<void> {
37-
'use step';
38-
const { stepStartedAt } = getStepMetadata();
39-
const durationMs =
40-
typeof param === 'string'
41-
? ms(param)
42-
: param.getTime() - Number(stepStartedAt);
43-
44-
if (typeof durationMs !== 'number' || durationMs < 0) {
45-
const message =
46-
param instanceof Date
47-
? `Invalid sleep date: "${param}". Expected a future date.`
48-
: `Invalid sleep duration: "${param}". Expected a valid duration string like "1s", "1m", "1h", etc.`;
49-
throw new Error(message);
50-
}
51-
52-
const endAt = +stepStartedAt + durationMs;
53-
const now = Date.now();
54-
if (now < endAt) {
55-
const remainingSeconds = (endAt - now) / 1000;
56-
const retryAfter = Math.min(remainingSeconds, MAX_SLEEP_DURATION_SECONDS);
57-
throw new RetryableError(
58-
`Sleeping for ${ms(retryAfter * 1000, { long: true })}`,
59-
{
60-
retryAfter,
61-
}
62-
);
63-
}
64-
}
65-
sleep.maxRetries = Infinity;
66-
678
/**
689
* A hoisted `fetch()` function that is executed as a "step" function,
6910
* for use within workflow functions.

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)