import wasm from './module.wasm';
const instance = await WebAssembly.instantiate(wasm, {});instantiateStreaming or passing a Buffer to either of them, but otherwise it's the same.
wrangler.toml.wrangler.toml right before the wrangler deploy action runs:wrangler@beta, i.e. wrangler@0.0.0-9ced24c9. This ensured I could use Wrangler 3 on macOS 11 “Big Sur” (see https://github.com/cloudflare/workers-sdk/issues/3457#issuecomment-1614424921). npx wrangler pages dev ./functions --local --live-reload --persist-to=./.wrangler --compatibility-date=2023-06-28 --d1=<BINDING_NAME>. response.clone() or request.clone() anywhere in my pages project. Are there any other ways I could be creating multiple branches of a single stream?setupMiniflareIsolatedStorage() required in a situation like this? I tested using the vitest describe and as far as I could tell the tests ran the same.ExportedHandler interface used in the Worker docs exposes fetch optionally ( fetch?: ...), which adds some extra checking that fetch is defined in tests. I made a custom ExportedHandler type with fetch required for the handler to avoid this. Is there a better approach?vitest-environment-miniflare": "2.x" until unit testing is supported in wrangler/miniflare 3? If not, how is everyone unit testing their workers at the moment with wrangler/miniflare 3?libc++1, libunwind), and then I had to resort to using wrangler@beta in order for things to work out.workerd is being actively worked on, but hopefully this will get more smooth down the line since the local DX is a bit annoying to having to sort out every few months...wrangler@beta resolves most of the dependency issues and unblocks many people now. There’s still a few regressions from v2, but it’s slowly getting there.unstable_dev and only getting this error when running in GitHub actions and not locallyprocess.env and will be available when running through wrangler/deployed. In next dev, you could try using a proxy like https://github.com/james-elicx/cf-bindings-proxyprocess.env in prod builds - if svelte uses that then yes. if not, i suppose it could probably be modified to accept a second parameter so that you can also pass in a custom variable to fallback to instead of process.envexport default {fetch,queue,schedule} ?instantiateStreamingwrangler@betawrangler@betawrangler@betawrangler@0.0.0-9ced24c9npx wrangler pages dev ./functions --local --live-reload --persist-to=./.wrangler --compatibility-date=2023-06-28 --d1=<BINDING_NAME>Your worker created multiple branches of a single stream (for instance, by calling `response.clone()` or `request.clone()`) but did not read the body of both branches. This is wasteful, as it forces the system to buffer the entire stream of data in memory, rather than streaming it through. This may cause your worker to be unexpectedly terminated for going over the memory limit. If you only meant to copy the request or response headers and metadata (e.g. in order to be able to modify them), use the appropriate constructors instead (for instance, `new Response(response.body, response)`, `new Request(request)`, etc).response.clone()request.clone()import { expect, test } from "vitest";
import worker from "./worker";
const describe = setupMiniflareIsolatedStorage();
interface WorkerBindings {
KV_NAMESPACE: KVNamespace;
R2_BUCKET: R2Bucket;
}
const env: WorkerBindings = getMiniflareBindings();
const ctx: ExecutionContext = new ExecutionContext();
describe("Given a request", () => {
test("when the URL path contains a valid KV key, correct value is returned", async () => {
await env.KV_NAMESPACE.put("testKey", "testValue");
const req = new Request<unknown, IncomingRequestCfProperties<unknown>>("https://example.com/kv/testKey");
const res = await worker.fetch(req, env, ctx);
expect(res.status).toEqual(200);
expect(await res.text()).toEqual("testValue");
});
test("when the URL path contains a valid R2 key, correct value is returned", async () => {
await env.R2_BUCKET.put("hello", "world");
const req = new Request<unknown, IncomingRequestCfProperties<unknown>>("https://example.com/r2/hello");
const res = await worker.fetch(req, env, ctx);
expect(res.status).toEqual(200);
expect(await res.text()).toEqual("world");
});
});setupMiniflareIsolatedStorage()describeExportedHandlerExportedHandlerfetch?: ...vitest-environment-miniflare": "2.x"libc++1libunwindexport default {fetch,queue,schedule}FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
1: 0xb090e0 node::Abort() [node]
2: 0xa1b60e node::FatalError(char const*, char const*) [node]
3: 0xce178a v8::Utils::ReportApiFailure(char const*, char const*) [node]
4: 0xb22165 [node]
5: 0x1a68837 llhttp__internal_execute [node]
6: 0xb252ad [node]
7: 0xbe50dd node::LibuvStreamWrap::OnUvRead(long, uv_buf_t const*) [node]
8: 0xbe54c4 [node]
9: 0x1558427 [node]
10: 0x1558c50 [node]
11: 0x155ee34 [node]
12: 0x154d058 uv_run [node]
13: 0xa43975 node::SpinEventLoop(node::Environment*) [node]
14: 0xbc7692 node::worker::Worker::Run() [node]
15: 0xbc7e28 [node]
16: 0x7f110c5a9b43 [/lib/x86_64-linux-gnu/libc.so.6]
17: 0x7f110c63ba00 [/lib/x86_64-linux-gnu/libc.so.6]
Aborted (core dumped)