Skip to content

Commit a2418e2

Browse files
authored
fix: correct passing executionCtx to context.cloudflare.ctx (#45)
1 parent 8399406 commit a2418e2

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

examples/cloudflare-pages/app/routes/_index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ export const loader = (args: LoaderFunctionArgs) => {
55
const extra = args.context.extra
66
const cloudflare = args.context.cloudflare
77
const myVarInVariables = args.context.hono.context.get('MY_VAR_IN_VARIABLES')
8-
return { cloudflare, extra, myVarInVariables }
8+
const isWaitUntilDefined = !!cloudflare.ctx.waitUntil
9+
return { cloudflare, extra, myVarInVariables, isWaitUntilDefined }
910
}
1011

1112
export default function Index() {
12-
const { cloudflare, extra, myVarInVariables } = useLoaderData<typeof loader>()
13+
const { cloudflare, extra, myVarInVariables, isWaitUntilDefined } = useLoaderData<typeof loader>()
1314
return (
1415
<div>
1516
<h1>Remix and Hono</h1>
@@ -21,6 +22,7 @@ export default function Index() {
2122
</h3>
2223
<h4>Extra is {extra}</h4>
2324
<h5>Var in Variables is {myVarInVariables}</h5>
25+
<h6>waitUntil is {isWaitUntilDefined ? 'defined' : 'not defined'}</h6>
2426
</div>
2527
)
2628
}

examples/cloudflare-pages/e2e.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ test('Should return 200 response - /', async ({ page }) => {
2121

2222
const contentH5 = await page.textContent('h5')
2323
expect(contentH5).toBe('Var in Variables is My variable set in c.set')
24+
25+
const contentH6 = await page.textContent('h6')
26+
expect(contentH6).toBe('waitUntil is defined')
2427
})
2528

2629
test('Should return 200 response - /api', async ({ page }) => {

examples/cloudflare-workers/app/routes/_index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ export const loader = (args: LoaderFunctionArgs) => {
55
const extra = args.context.extra
66
const cloudflare = args.context.cloudflare
77
const myVarInVariables = args.context.hono.context.get('MY_VAR_IN_VARIABLES')
8-
return { cloudflare, extra, myVarInVariables }
8+
const isWaitUntilDefined = !!cloudflare.ctx.waitUntil
9+
return { cloudflare, extra, myVarInVariables, isWaitUntilDefined }
910
}
1011

1112
export default function Index() {
12-
const { cloudflare, extra, myVarInVariables } = useLoaderData<typeof loader>()
13+
const { cloudflare, extra, myVarInVariables, isWaitUntilDefined } = useLoaderData<typeof loader>()
1314
return (
1415
<div>
1516
<h1>Remix and Hono</h1>
@@ -21,6 +22,7 @@ export default function Index() {
2122
</h3>
2223
<h4>Extra is {extra}</h4>
2324
<h5>Var in Variables is {myVarInVariables}</h5>
25+
<h6>waitUntil is {isWaitUntilDefined ? 'defined' : 'not defined'}</h6>
2426
</div>
2527
)
2628
}

examples/cloudflare-workers/e2e.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ test('Should return 200 response - /', async ({ page }) => {
2121

2222
const contentH5 = await page.textContent('h5')
2323
expect(contentH5).toBe('Var in Variables is My variable set in c.set')
24+
25+
const contentH6 = await page.textContent('h6')
26+
expect(contentH6).toBe('waitUntil is defined')
2427
})
2528

2629
test('Should return 200 response - /api', async ({ page }) => {

src/remix.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ export const createGetLoadContextArgs = (c: Context): GetLoadContextArgs => {
2828
cloudflare: {
2929
env: c.env,
3030
cf: c.req.raw.cf,
31-
ctx: {
32-
...c.executionCtx,
33-
},
31+
ctx: c.executionCtx,
3432
// @ts-expect-error globalThis.caches is not typed
3533
caches: globalThis.caches ? caches : undefined,
3634
},

0 commit comments

Comments
 (0)