workers-rs
workers-rs copied to clipboard
`import shim from ". /shim.mjs"` worked fine on cloudflare pages a couple weeks ago, now I get `TypeError: an.fetch is not a function`
import shim from "./shim.mjs"
export async function onRequest(context) {
var rsp;
try {
rsp = shim.fetch(context.request, context.env, context);
}
catch(e) {
return new Response("err:"+ e )
}
return rsp;
}
This code used to work fine on cloudflare pages, now it gets TypeError: An.fetch is not a function
Which version of worker-build are you using? It sounds like Pages may not support the new WorkerEntrypoint interface introduced for RPC.
Edit: are you supplying a custom JavaScript entrypoint script?
@kflansburg
Thanks.
After changing the version of worker-build back to 0.1.0 everything is fine.
Hopefully maybe the new WorkerEntrypoint interface could have some compatibility with the current Cloudflare Pages.
@kflansburg
Thanks.
After changing the version of worker-build back to 0.1.0 everything is fine.
Hopefully maybe the new WorkerEntrypoint interface could have some compatibility with the current Cloudflare Pages.
What is the source of the code you included? Is Pages supplying that or are you using a custom entrypoint script? That may need to be updated to the new shim provided by worker-build
I'm using this code as Cloudflare Pages Fucntions and it works fine with [email protected] + [email protected]
@kflansburg
I'm using this code as Cloudflare Pages Fucntions and it works fine with [email protected] + [email protected]
@kflansburg
Yes, what I'm saying is that the bug may not be with Pages, but with the JavaScript you posted in your first message. Where did that come from?
Yes, but where did the code in your first message come from? Is that your code? If so, you should update it to be compatible with the new interface.
@kflansburg
After changing the version of worker-build back to 0.1.0 everything is fine.
Sorry, I wrote the wrong version number in this sentence. I actually switched back to version 0.0.10
You can compile the hello-world template to get index.wasm and shim.mjs then test it as Pages Functions using the code in myfirst message.
The problem occurs when you use [email protected] & [email protected]
# Cargo.toml
worker = { version = "0.2.0" }
worker-macros = { version = "0.2.0" }
// ./functions/_middleware.js
import * as shim from "./shim.mjs"
# Cargo.toml worker = { version = "0.2.0" } worker-macros = { version = "0.2.0" }
// ./functions/_middleware.js import * as shim from "./shim.mjs"
Thanks bro