Nope. The workaround is: ```js let variable; export async function onRequestGet(context) { if (
Nope. The workaround is:
let variable;
export async function onRequestGet(context) {
if (variable == null) {
variable = initFromEnv(env);
}
// ...use variable
}await points (no IO) inside initFromEnv then you should be good.await'ing inside the initFromEnv then there's concurrency issues because Workers may switch the request they're serving on await points.{"env":"prod"} , there's no sub-fetch or database queries going on. The endpoint sets cache-control: private. On my BetterStack graph, I'm seeing lots of requests which take ~1 second and even a handful which take ~2 seconds. I switched to paid workers, but don't see any difference in the graph. So a couple questions:
Response.json()Workers with a D1 binding will always be placed in a data center near the location of the D1 database they are bound to => I do have a D1 binding.pnpx wrangler dev functions it keeps saying pnpx wrangler dev functions/get_info/index.js my script works perfectly. 
context.request object is completely empty?context.request.url to at least exist?JSON.stringify(context) look like:http://localhost:8788/api/auth-callback?token=aaabbbJSON.stringify (and sometimes console.log) - it doesn't handle properties on most objects.context.request.url directly

wrangler pages functions build ... then run the compiled file via plain wrangler dev in local and remote mode and wrangler deploy All worked fine. Also the compiled script was 700kb minified gzipped.build.minify in my vite config and it deployed. I guess I am closer to the 1mb limit than I thought.wrangler pages deploy minify by default?wrangler pages deploy show the uploaded size of the worker bundle? (Right now it just shows Uploading Functions bundle) (Edit I found an existing feature request)HTMLRewriter would be the way to do this, but I'm not sure now I'm actually trying to implement it.HTMLRewriter I end up with:Element doesn't (as far as I can tell) implement any methods to get the children elements, I'm not sure how I should progress.initFromEnv{"env":"prod"}cache-control: privateResponse.json()Workers with a D1 binding will always be placed in a data center near the location of the D1 database they are bound to├─ functions
│ └─ get_info
│ └─ index.jspnpx wrangler dev functions [ERROR] The entry-point file at "functions" was not found.
The provided entry-point path, "functions", points to a directory, rather than a file.pnpx wrangler dev functions/get_info/index.jscontext.requestcontext.request.urlcontext.request.urlJSON.stringify(context)http://localhost:8788/api/auth-callback?token=aaabbbJSON.stringifywrangler pages functions build ...build.minifywrangler pages deploywrangler pages deployUploading Functions bundleHTMLRewriterHTMLRewriterElement{
"request": {},
"functionPath": "/api/auth-callback",
"params": {},
"data": {},
"env": {
"ASSETS": {}
}
}const items = Array.from(parsedData.querySelectorAll("#example-parent")).map(parent => {
const thingOne = parent.querySelector("#example-thing-one").getAttribute("content")
const thingTwo = parent.querySelector("#example-thing-two").getAttribute("content");
return { thingOne, thingTwo }
});class ExampleElementHandler implements HTMLRewriterElementContentHandlers{
element(element: Element): void {
element.??? // how do I access the children
}
}
const parsedData = new HTMLRewriter()
.on("#example-paret", new ExampleElementHandler())
.transform(res);export const onRequest: PagesFunction<{}> = async (context) => {
const req = context.request;
return fetch(req);
}import { filesize } from 'filesize';
import fs from 'node:fs/promises';
import { temporaryDirectoryTask } from 'tempy';
import { $ } from 'zx';
$.verbose = false;
async function printFileSize(memo, path) {
const stats = await fs.stat(path);
console.log(memo + ': ' + filesize(stats.size));
}
console.log(`check-worker-size.js Final Worker Size:`);
await temporaryDirectoryTask(async (outdir) => {
await $`pnpm wrangler pages functions build --outdir ${outdir}`;
await printFileSize('Raw', `${outdir}/index.js`);
await $`gzip ${`${outdir}/index.js`}`;
await printFileSize('Gzipped', `${outdir}/index.js.gz`);
});
await temporaryDirectoryTask(async (outdir) => {
await $`pnpm wrangler pages functions build --minify --outdir ${outdir}`;
await printFileSize('Minified', `${outdir}/index.js`);
await $`gzip ${`${outdir}/index.js`}`;
await printFileSize('Minified & Gzipped', `${outdir}/index.js.gz`);
});