Nicolaas
03/03/2023, 1:17 PMAdrian (Launchpad Cohort)
03/03/2023, 1:21 PMts
const hexBuffer = await r.arrayBuffer()
let bytes = new Uint8Array(hexBuffer as ArrayBuffer)
recursive use of an object detected which would lead to unsafe aliasing in rust
looks like a worker runtime thing. note that only one image is doing this. image is downloaded finekian
03/03/2023, 1:30 PMkian
03/03/2023, 1:31 PMkian
03/03/2023, 1:34 PMkian
03/03/2023, 1:34 PMAdrian (Launchpad Cohort)
03/03/2023, 1:37 PMkian
03/03/2023, 1:37 PMkian
03/03/2023, 1:38 PMAdrian (Launchpad Cohort)
03/03/2023, 1:39 PM(warn) Trace resource limit exceeded; subsequent logs not recorded.
ts
await initialize(wasm).catch((e: Error) => {
//We don't log the expected error
if (!e.message.startsWith('Already initialized.')) console.error(e)
})
const ogImage = await svg2png(svg)
kian
03/03/2023, 1:47 PMAdrian (Launchpad Cohort)
03/03/2023, 1:47 PMAdrian (Launchpad Cohort)
03/03/2023, 1:47 PMsvg2png
Adrian (Launchpad Cohort)
03/03/2023, 1:52 PMAdrian (Launchpad Cohort)
03/03/2023, 1:52 PMkian
03/03/2023, 1:53 PMinitialized
and only init inside an if checkkian
03/03/2023, 1:54 PMts
import esbuild from "esbuild-wasm";
import wasm from "../node_modules/esbuild-wasm/esbuild.wasm";
let initialised = false;
globalThis.performance = Date;
export default {
async fetch(): Promise<Response> {
if (!initialised) {
await esbuild.initialize({
wasmModule: wasm,
worker: false,
});
initialised = true;
}
return new Response("Hello World");
},
};
Example from Adrian (Launchpad Cohort)
03/03/2023, 1:59 PMKavatch
03/03/2023, 2:00 PMssl_client_certificate /etc/ssl/certs/cloudflare-origin.pem;
ssl_verify_client on;
About all of this there is also this excellent blog post: https://blog.jfx.ac/securing-nginx-origin-with-cloudflare.htmlAdrian (Launchpad Cohort)
03/03/2023, 2:03 PMts
let ogImage = null
try {
if (!initialized) {
await initialize(wasm).catch((e: Error) => {
//We don't log the expected error
console.debug("Couldn't initialize wasm", e)
if (!e.message.startsWith('Already initialized.')) console.error(e)
})
}
console.debug('initialized wasm')
initialized = true
ogImage = await svg2png(svg)
} catch (e) {
console.error('Failed to convert svg to png')
console.error(e)
return ''
}
in some instances however now we are getting ✘ [ERROR] Error: Promise will never complete.
kian
03/03/2023, 2:05 PMAdrian (Launchpad Cohort)
03/03/2023, 2:05 PMAdrian (Launchpad Cohort)
03/03/2023, 2:09 PMdale
03/03/2023, 2:19 PMdale
03/03/2023, 2:19 PMdale
03/03/2023, 2:26 PMAdrian (Launchpad Cohort)
03/03/2023, 3:08 PMts
return WebAssembly.instantiate(
wasmModule,
imports
)
Adrian (Launchpad Cohort)
03/03/2023, 3:10 PMAdrian (Launchpad Cohort)
03/03/2023, 3:11 PM[object WebAssembly.Instance] { memory: {} }
(error) RuntimeError: unreachable
Adrian (Launchpad Cohort)
03/03/2023, 3:22 PM