weave icon indicating copy to clipboard operation
weave copied to clipboard

Node SDK gives undecipherable errors when calling trace server

Open pjlsergeant opened this issue 7 months ago • 0 comments

When calls to the trace server fail, the user gets an unhelpful error:

node:internal/process/promises:392
      new UnhandledPromiseRejection(reason);
      ^

UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<_Response>".
    at throwUnhandledRejectionsMode (node:internal/process/promises:392:7)
    at processPromiseRejections (node:internal/process/promises:475:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:106:32) {
  code: 'ERR_UNHANDLED_REJECTION'
}

This is because swagger-typescript-api ends up throwing the response error itself rather than an error object, and src/weaveClient.ts doesn't wrap all of its calls to TraceServerApi in proper error handling; the response object itself gets bubbled up (which doesn't serialize well) and doesn't have a stack.

This makes the Node SDK essentially unusable; if you trip this error and don't spend the several hours I just have combing through code trying to find the source, you have absolutely no idea why it's blowing up. Making this worse is the async nature of the library -- really, it is almost impossible to find where the error originates without a significant investment in time and energy for the library user.

pjlsergeant avatar May 14 '25 13:05 pjlsergeant