An open API service indexing awesome lists of open source software.

https://github.com/rocicorp/cf-global-state


https://github.com/rocicorp/cf-global-state

Last synced: 16 days ago
JSON representation

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`.