xeon06
xeon06
Explore posts from servers
CDCloudflare Developers
Created by xeon06 on 10/12/2024 in #workers-help
API to set worker environment variable?
Hey folks, I'm looking for an HTTP API to set a Worker's environment variable. Digging into Wrangler, another member of the community found this for secrets: /accounts/account_id/workers/scripts/script_name/secrets https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/secret/index.ts#L170-L185 But I'm not sure if it can apply to regular plain text env vars, and am not finding anything else documented anywhere.
3 replies
CDCloudflare Developers
Created by xeon06 on 10/9/2024 in #workers-help
Service binding RPC method null
I have a project with a service binding I call like this:
const result = await ctx.runtime.env.CRYPTO.encrypt(arg)
const result = await ctx.runtime.env.CRYPTO.encrypt(arg)
Despite the service being bound correctly, I ge this in production:
TypeError: ctx.runtime.env.CRYPTO.encrypt is not a function
TypeError: ctx.runtime.env.CRYPTO.encrypt is not a function
Logging this
console.log(
ctx.runtime.env.CRYPTO.fetch,
typeof ctx.runtime.env.CRYPTO.fetch,
ctx.runtime.env.CRYPTO.encrypt,
typeof ctx.runtime.env.CRYPTO.encrypt,
)
console.log(
ctx.runtime.env.CRYPTO.fetch,
typeof ctx.runtime.env.CRYPTO.fetch,
ctx.runtime.env.CRYPTO.encrypt,
typeof ctx.runtime.env.CRYPTO.encrypt,
)
Gives
"function fetch() { [native code] }",
"function",
null,
"undefined"
"function fetch() { [native code] }",
"function",
null,
"undefined"
I can rewrite it using fetch, but are these supposed to work?
8 replies
CDCloudflare Developers
Created by xeon06 on 10/9/2024 in #pages-help
Debugging service binding
Hey folks, I have a service binding I call like this:
const result = await ctx.runtime.env.CRYPTO.encrypt(arg)
const result = await ctx.runtime.env.CRYPTO.encrypt(arg)
The service is bound on my pages project, but I get this:
TypeError: ctx.runtime.env.CRYPTO.encrypt is not a function
TypeError: ctx.runtime.env.CRYPTO.encrypt is not a function
I can confirm the encrypt method is on the class when I do edit code. I'm kind of at a loss for what else to try.
3 replies
CDCloudflare Developers
Created by xeon06 on 10/8/2024 in #workers-help
Set secrets via HTTP
Is there any way to set a worker secret via HTTP? I see there's something for Worker Platform but not finding much for workers except for the wrangler command, but I want to do it through code...
3 replies
CDCloudflare Developers
Created by xeon06 on 10/1/2024 in #workers-help
Durable opbject bindings?
Do durable objects need to be bound through the dashboard? There's a space for it, but I have no dur
1 replies
CDCloudflare Developers
Created by xeon06 on 9/7/2024 in #workers-help
Setting DO script_name only in dev?
Hey folks, in order to work with Durable Objects with getPlatformProxy, you must use a separate worker and script_name. That's all fine, but is there a way to ensure the script_name is only set in dev, since that seems to have an effect in prod too?
[durable_objects]
bindings = [
{ name = "DATA_NOTIFIER", class_name = "DataNotifier", script_name = "dev-data-notifier-worker" }
]
[durable_objects]
bindings = [
{ name = "DATA_NOTIFIER", class_name = "DataNotifier", script_name = "dev-data-notifier-worker" }
]
1 replies
CDCloudflare Developers
Created by xeon06 on 9/5/2024 in #workers-help
RPC dispose not available?
Hey folks, I'm calling an RPC worker locally from a Cloudflare Astro project, 11.0.4 on the CF Astro adapter, Wrangler 3.74.0 When I call an RPC method, I get this:
An RPC stub was not disposed properly. You must call dispose() on all stubs in order to let the other side know that you are no longer using them. You cannot rely on the garbage collector for this because it may take arbitrarily long before actually collecting unreachable objects. As a shortcut, calling dispose() on the result of an RPC call disposes all stubs within it.
However there is nothing on dispose or [Symbol.dispose] for me to call, both are undefined. Am I in version incompatibility hell?
2 replies
CDCloudflare Developers
Created by xeon06 on 8/12/2024 in #workers-help
RPC + cron?
Hey folks, I'm trying to add RPC to a worker that already has a scheduled handler for cron. It looks like inheriting from WorkerEntrypoint messes up any other method such as scheduled..?
3 replies
CDCloudflare Developers
Created by xeon06 on 2/1/2024 in #workers-help
WebAssembly.instantiate(): Wasm code generation disallowed by embedder
Hey folks, I'm trying to get a Wasm library to work in a Pages function, but I'm having the hardest time instantiating it. At first I was fetching the .wasm binary to instantiate, but someone in #pages-help told me it had to be bundled within the _worker.js script. Okay, now it's a UInt8Array directly in the _worker.js script but I still get this error. Is there more information on how the wasm binary should be bundled? Is it a specific format that will make the CF worker accept it?
15 replies
CDCloudflare Developers
Created by xeon06 on 2/1/2024 in #pages-help
Deployment failure logs
No description
2 replies
CDCloudflare Developers
Created by xeon06 on 1/31/2024 in #pages-help
CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder
Hey folks, I'm trying to run a wasm file compiled by emscripten on CF workers. It's working fine locally, but when I try it in production I get:
failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder
failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder
This page seems to indicate that WebAssembly.instantiate should work, am I missing something? https://developers.cloudflare.com/workers/runtime-apis/webassembly/
13 replies
CDCloudflare Developers
Created by xeon06 on 1/15/2024 in #pages-help
Accessing assets from pages functions
Hey folks, I'm building an app on Pages using the CloudFlare Astro adapter. I'm trying to access some of my static assets in a function, but Astro.locals.runtime.env.ASSETS seems to be undefined, both in directory or advanced mode. Does anyone know if there's any extra bits of config I need to do or?
10 replies
CDCloudflare Developers
Created by xeon06 on 12/18/2023 in #workers-help
Email worker inside of a pages repo?
Hey folks, I'm trying to develop something that uses both pages for deployment of a frontend / backend website, but also an email worker. I want to try to keep the code in the same repo, but I realize that it will need to be separate deployments on CloudFlare, since pages doesn't support email routing. Are there existing patterns to keep both my pages and my email worker's code in the same repo while still being able to deploy everything?
5 replies