Closed philippviereck closed 2 months ago
With these "patches" I can run the worker: https://github.com/philippviereck/otel-cf-workers/tree/debugging
Seems to crash when doing a POST
to turso. Could it be something with the fetch()
of https://www.npmjs.com/package/@libsql/client ?
Hi @philippviereck, were you able to fix this ?
@mehulmathur16 no, I was not. Haven't had the time so far...
It never crashed on me so far but those are really just VERY DIRTY patches to catch uncaught errors and give hints as to where the critical sections are... I did not put any thought into it, I just wanted the crashes to go away.
Okay got it, thanks.
@philippviereck this issue is temporarily fixed in https://github.com/mehulmathur16/otel-cf-workers
These patches don't quite get to the root cause of the issue, and will lead to spans being created not in the tree so traces will be broken.
For some reason for some fetch calls AsyncLocalStorage looses the context.
There are a few github issues about this but none of them have a clear fix for this problem
https://github.com/nodejs/node/issues/41285
In the scenario I am looking into this for it works for planetscale database fetches, but not when that planetscale fetch is passed into drizzle-orm. I'd suggest something similar is happening with the turso client.
Should be solved by: https://github.com/cloudflare/workerd/issues/1513#issuecomment-1954456751
https://github.com/evanderkoogh/otel-cf-workers/blob/2d370cb9098a9066da3ba2b3102d6f29e5c99c31/src/config.ts#L12
I use SvelteKit on Cloudflare workers. I modified the SvelteKit Workers Adapter (this file) such that it instruments the the fetch handler using otel-cf-workers.
The worker-file where SvelteKit gets 'injected' looks like this then.