Open deronek opened 7 months ago
Thanks for opening this issue!
The instrumentHandle.ts
implementation mimics @sentry/javascript/sveltekit/src/server/handle.ts
.
Personally, I would like to see this library serve as a workaround until @sentry/javascript
officially supports cloudflare, and eventually go back to @sentry/javascript
.
Adding features is all well and good, but if we move too far away from the original, it will be difficult to go back to the official @sentry/javascript
.
However, I do understand that such features are important for some people. If there are many similar comments from others, I would consider implementing it.
I understand and agree that it's best for this library to keep its implementation as close to @sentry/sveltekit
.
It would obviously be preferable to get this behavior discussed and implemented in the latter library, but since I cannot use it in production (hosting on CF), it might not be feasible for me to do it in the near future.
Hi, I was trying to use this library but I'm having some problems getting consistent error handling in all possible cases.
In SvelteKit, we use built-in
error
function to "throw" (in SvelteKit 2, not explicitly) customHttpError
to initiate HTTP error handling on the framework side, to respond with a custom HTTP status code. As an example:However, in current implementation, the error will not be catched by this library and we will just send a response back. This is because:
handleError
hook, DocsinstrumentHandle
forhandle
hook does not catch thisHttpError
. When theevent
resolves, error was already handled by SvelteKIt, setting the status code and the message.res
gets returned withResponse
. https://github.com/jill64/sentry-sveltekit-cloudflare/blob/e34b9516861517cf4f11f7935aad90609a3d4e0c/src/server/instrumentHandle.ts#L54-L56I'm positive that it's not expected to be working this way, since we see a
catch
block in the same function: https://github.com/jill64/sentry-sveltekit-cloudflare/blob/e34b9516861517cf4f11f7935aad90609a3d4e0c/src/server/instrumentHandle.ts#L64-L68And below code in
sendErrorToSentry
: https://github.com/jill64/sentry-sveltekit-cloudflare/blob/e34b9516861517cf4f11f7935aad90609a3d4e0c/src/server/sendErrorToSentry.ts#L10-L18So in my analysis, I think it's not possible to have both automatic Sentry error handling (it's still possible to throw normal JavaScript
Error
, which will force status code 500) and custom status codes/response. Is this expected? Could you analyze the possibility of handling this condition in your library? I'm happy to help with the implementation.