https://github.com/rocicorp/cf-do-js-exec-context
https://github.com/rocicorp/cf-do-js-exec-context
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rocicorp/cf-do-js-exec-context
- Owner: rocicorp
- Created: 2023-09-20T00:31:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-21T18:44:17.000Z (almost 3 years ago)
- Last Synced: 2025-01-13T19:17:24.519Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://cf-do-js-exec-context-test.replicache.workers.dev/?name1=foo&name2=bar
- Size: 33.2 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cf-do-js-exec-context
A test Cloudflare worker and durable object which demonstrates that
wrangler dev uses a single JavaScript execution context for workers and
Durable Objects of different classes and/or ids. This behavior differs from
the deployed behavior.
**Response from `wrangler dev` looks like:**
```
Worker js exec context id: snfxxmas
DOClass1 foo response: DO id: znr0fq82, js context id: snfxxmas
DOClass2 bar response: DO id: z3a83ub6, js context id: snfxxmas
DOClass1 foo response: DO id: znr0fq82, js context id: snfxxmas
DOClass2 bar response: DO id: z3a83ub6, js context id: snfxxmas
```
Indicating the worker and Durable Object instances are all sharing the same
JavaScript execution context.
**Response from `wrangler dev --remote` looks like:**
```
Worker js exec context id: q5q0i2xk
DOClass1 foo response: DO id: cahimg3f, js context id: tk2dp2f
DOClass2 bar response: DO id: jfn3p28p, js context id: tk2dp2f
DOClass1 foo response: DO id: cahimg3f, js context id: tk2dp2f
DOClass2 bar response: DO id: jfn3p28p, js context id: tk2dp2f
```
Indicating the worker has its own JavaScript Execution Context and the Durable
Object instances are sharing the same JavaScript execution context.
**Response from `wrangler publish` output looks like:**
```
Worker js exec context id: l7xrtr9j
DOClass1 foo response: DO id: fci8u6tn, js context id: j8q3vagr
DOClass2 bar response: DO id: pwdem3v, js context id: 0jf132k
DOClass1 foo response: DO id: fci8u6tn, js context id: j8q3vagr
DOClass2 bar response: DO id: pwdem3v, js context id: 0jf132k
```
Indicating the worker and Durable Object instances are all in different
JavaScript execution contexts.
## Running Locally
```bash
npm install
npx wrangler dev
```
Then open http://localhost:8787?name1=foo&name2=bar in your browser of choice.
## Running on Cloudflare
```
npm install
npx wrangler publish
```
Then open the url for the worker output by the above wrangler publish command.
Like https://cf-do-js-exec-context-test.my-team.workers.dev?name1=foo&name2=bar