Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import shim from ". /shim.mjs" worked fine on cloudflare pages a couple weeks ago, now I get TypeError: an.fetch is not a function #576

Closed
Jhonfunk opened this issue May 14, 2024 · 7 comments

Comments

@Jhonfunk
Copy link

Jhonfunk commented May 14, 2024

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

@kflansburg
Copy link
Member

kflansburg commented May 14, 2024

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?

@Jhonfunk
Copy link
Author

Jhonfunk commented May 14, 2024

@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
Copy link
Member

@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

@Jhonfunk
Copy link
Author

Jhonfunk commented May 14, 2024

I'm using this code as Cloudflare Pages Fucntions and it works fine with worker-build@0.1.0 + worker-rs@0.1.0

@kflansburg

@kflansburg
Copy link
Member

I'm using this code as Cloudflare Pages Fucntions and it works fine with worker-build@0.1.0 + worker-rs@0.1.0

@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?

@kflansburg
Copy link
Member

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.

@Jhonfunk
Copy link
Author

Jhonfunk commented May 14, 2024

@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 worker-build@0.1.0 & worker-rs@0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants