https://github.com/rocicorp/cf-global-state
https://github.com/rocicorp/cf-global-state
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rocicorp/cf-global-state
- Owner: rocicorp
- Created: 2023-09-15T05:52:00.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T16:30:26.000Z (almost 3 years ago)
- Last Synced: 2025-10-30T21:50:05.153Z (9 months ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cf-worker-clocks
A test Cloudflare worker and durable object which demonstrates problems that
can arise from Cloudflare's reuse of JavaScript execution context.
## Demonstrating the issue
```
npm install
npx wrangler publish
```
Then in a browser open:
`https:///sleepInLock?seconds=40000`
or
`https:///fetchInLock?seconds=40000`
Then without modifying the code run
```
npx wrangler publish
```
or
```
npx wrangler tail
```
The publish/tail will cause the above sleepInLock/fetchInLock request to be
cancelled, and the DO to throw an exception:
`Durable Object reset because its code was updated.`
Then in a browser open:
`https:///checkLock`
Which will show that the lock is still held, because the timeout/fetch for the
cancelled request did not resolve or reject, and so the lock was not released.
The lock will now be stuck locked until the Durable Object is restarted
in a different JavaScript Execution Context. This can be forced by slightly
modifying the code and running `wrangler publish`.