astro workflow ignores wrangler.jsonc and tries to bind to "USER_WORKFLOW" (not something I know of)
trying out CF pages with astro and a workflow
> pdse-the-wall-of-us@0.0.1 dev
> astro dev
22:32:33 [@astrojs/cloudflare] Enabling sessions with filesystem storage. Be sure to define a KV binding named "SESSION".
22:32:33 [@astrojs/cloudflare] If you see the error "Invalid binding `SESSION`" in your build output, you need to add the binding to your wrangler config file.
22:32:33 [WARN] [config] The adapter @astrojs/cloudflare has limited support for "sharp". Certain features may not work as expected.
22:32:33 [WARN] [adapter] Cloudflare does not support sharp. You can use the `compile` image service to compile images at build time. It will not work for any on-demand rendered images.
Worker "workflows:increment-and-fact"'s binding "USER_WORKFLOW" refers to service "core:user:pdse-collective-curiosity-wall" with a named entrypoint "IncrementAndFactWorkflow", but "core:user:pdse-collective-curiosity-wall" has no such named entrypoint.
22:32:33 [ERROR] [@astrojs/cloudflare] An unhandled error occurred while running the "astro:server:setup" hook
The Workers runtime failed to start. There is likely additional logging output above.
Location:
/Users/norfeldt/repos/pdse-the-wall-of-us/node_modules/miniflare/dist/src/index.js:15987:13
> pdse-the-wall-of-us@0.0.1 dev
> astro dev
22:32:33 [@astrojs/cloudflare] Enabling sessions with filesystem storage. Be sure to define a KV binding named "SESSION".
22:32:33 [@astrojs/cloudflare] If you see the error "Invalid binding `SESSION`" in your build output, you need to add the binding to your wrangler config file.
22:32:33 [WARN] [config] The adapter @astrojs/cloudflare has limited support for "sharp". Certain features may not work as expected.
22:32:33 [WARN] [adapter] Cloudflare does not support sharp. You can use the `compile` image service to compile images at build time. It will not work for any on-demand rendered images.
Worker "workflows:increment-and-fact"'s binding "USER_WORKFLOW" refers to service "core:user:pdse-collective-curiosity-wall" with a named entrypoint "IncrementAndFactWorkflow", but "core:user:pdse-collective-curiosity-wall" has no such named entrypoint.
22:32:33 [ERROR] [@astrojs/cloudflare] An unhandled error occurred while running the "astro:server:setup" hook
The Workers runtime failed to start. There is likely additional logging output above.
Location:
/Users/norfeldt/repos/pdse-the-wall-of-us/node_modules/miniflare/dist/src/index.js:15987:13
astro.config.mjs
// https://astro.build/config
export default defineConfig({
output: 'server',
adapter: cloudflare({
platformProxy: {
enabled: true, // Should allows frontmatter to have to Cloudflare Bindings (env)
},
}),
// https://astro.build/config
export default defineConfig({
output: 'server',
adapter: cloudflare({
platformProxy: {
enabled: true, // Should allows frontmatter to have to Cloudflare Bindings (env)
},
}),
1 Reply
src/index.ts
// @ts-ignore - Workflow types not yet in @cloudflare/workers-types package
import { WorkflowEntrypoint, WorkflowStep } from 'cloudflare:workers'
// @ts-ignore
import type { WorkflowEvent } from 'cloudflare:workers'
export type Params = { number: number }
export type State = { incremented: number; fact: string }
export class IncrementAndFactWorkflow extends WorkflowEntrypoint<Env, Params> {
async run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<State> {
const incremented = await step.do('increment', async () => event.payload.number + 1)
await step.sleep('wait 3 seconds', '3 seconds')
const fact = await step.do('fetch fact', async () => {
const resp = await fetch(`http://numbersapi.com/${incremented}/trivia?json`)
// @ts-ignore - Type not defined in TypeScript but available at runtime
const data = await resp.json()
return data.text
})
return { incremented, fact }
}
}
export type Env = { MY_WORKFLOW: any } // Use 'any' for now as Workflow type may not be defined
// @ts-ignore - Workflow types not yet in @cloudflare/workers-types package
import { WorkflowEntrypoint, WorkflowStep } from 'cloudflare:workers'
// @ts-ignore
import type { WorkflowEvent } from 'cloudflare:workers'
export type Params = { number: number }
export type State = { incremented: number; fact: string }
export class IncrementAndFactWorkflow extends WorkflowEntrypoint<Env, Params> {
async run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<State> {
const incremented = await step.do('increment', async () => event.payload.number + 1)
await step.sleep('wait 3 seconds', '3 seconds')
const fact = await step.do('fetch fact', async () => {
const resp = await fetch(`http://numbersapi.com/${incremented}/trivia?json`)
// @ts-ignore - Type not defined in TypeScript but available at runtime
const data = await resp.json()
return data.text
})
return { incremented, fact }
}
}
export type Env = { MY_WORKFLOW: any } // Use 'any' for now as Workflow type may not be defined
wrangler.jsonc
{
// ...
"main": "src/index.ts",
"workflows": [
{
"name": "increment-and-fact",
"binding": "MY_WORKFLOW",
"class_name": "IncrementAndFactWorkflow"
}
]
}
{
// ...
"main": "src/index.ts",
"workflows": [
{
"name": "increment-and-fact",
"binding": "MY_WORKFLOW",
"class_name": "IncrementAndFactWorkflow"
}
]
}