workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

The script will never generate a response: worker-build should emit all code inside a closure in a fetch function

Open samdenty opened this issue 2 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

What version of workers-rs are you using?

0.0.0

Describe the bug

Currently, the emitted code for worker-build has everything defined on the top-level.

I'm not sure why, but for some reason variables defined in the top level are re-used across requests.

I'm using the cached crate in my project, and because the wasm memory is re-used across requests - it stops working and hangs with The script will never generate a response.

I'm not sure if this is the intended behaviour, re-using the wasm memory across requests - maybe it was done for perf reasons?

But anyways I've ran into this issue of randomly hanging workers loads of times, and it's really annoying. I think the default should be not to re-use memory across requests

Steps To Reproduce

No response

samdenty avatar Dec 31 '22 21:12 samdenty

I'm not sure if this is the intended behaviour, re-using the wasm memory across requests

This is intentional but I'm not too sure on why this would cause the cached to crash, can you make a small reproducible example?

zebp avatar Jan 07 '23 18:01 zebp

This only fixes the script will never generate response error for some cases, but I'm now running into https://github.com/cloudflare/rustwasm-worker-template/issues/22 which I think may? be the root cause

samdenty avatar Jan 07 '23 22:01 samdenty