This function works as expected: ```async function wait(ms: number) { await new Promise((resolve)
This function works as expected:
and this waits until completion before returning:
and this waits until completion before returning:
async function wait(ms: number) {
await new Promise((resolve) => setTimeout(resolve, ms));
console.log("hello");
}await init((imports) => WebAssembly.instantiate(wasm, imports));
const encoder = new Tiktoken(
model.bpe_ranks,
model.special_tokens,
model.pat_str
);
async function handleCountTokens(data: string) {
return new Promise((resolve, reject) => {
const tokens = encoder.encode(data);
// encoder.free();
resolve({
tokens_count: tokens.length,
});
});
}ctx.waitUntil(handleCountTokens(text));async there.workerd


no support for .ts
npx wrangler pages dev -- SERVER COMMAND . You are also able to get the logs of your functions by pressing "d"._worker file to configured with wrangler v3.22.1. Tested with a fresh npm create cloudflare@latest install with svelte . Picked both the TypeScript and JavaScript versions but neither are working
ctx.waitUntil(handleCountTokens(text));workerd.tsnpx wrangler pages dev -- SERVER COMMAND_workerv3.22.1npm create cloudflare@latestsvelteexport default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname.startsWith('/api/')) {
return new Response('Ok');
}
return env.ASSETS.fetch(request);
}
};