Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack trace not including the calling location. #2622

Closed
agirorn opened this issue Sep 24, 2021 · 3 comments · Fixed by #2983
Closed

Stack trace not including the calling location. #2622

agirorn opened this issue Sep 24, 2021 · 3 comments · Fixed by #2983

Comments

@agirorn
Copy link

agirorn commented Sep 24, 2021

When an error is rejected from a query, then the stack trace is not complete. It does not include the calling code and that makes finding and fixing the errors harder than it needs to be. Could we not improve this in the module instead of having users add some wrapping try-catch logic to try to improve this?

**Sample of and error I just got"

  error: operator does not exist: text = integer
        at Parser.parseErrorMessage (/Users/aegiro/code/project/node_modules/pg-protocol/src/parser.ts:369:69)
        at Parser.handlePacket (/Users/aegiro/code/project/node_modules/pg-protocol/src/parser.ts:188:21)
        at Parser.parse (/Users/aegiro/code/project/node_modules/pg-protocol/src/parser.ts:103:30)
        at Socket.<anonymous> (/Users/aegiro/code/project/node_modules/pg-protocol/src/index.ts:7:48)
        at Socket.emit (events.js:400:28)
        at addChunk (internal/streams/readable.js:290:12)
        at readableAddChunk (internal/streams/readable.js:265:9)
        at Socket.Readable.push (internal/streams/readable.js:204:10)
        at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
      length: 200,
      severity: 'ERROR',
      code: '42883',
      detail: undefined,
      hint: 'No operator matches the given name and argument types. You might need to add explicit type casts.',
      position: '295',
      internalPosition: undefined,
      internalQuery: undefined,
      where: undefined,
      schema: undefined,
      table: undefined,
      column: undefined,
      dataType: undefined,
      constraint: undefined,
      file: 'parse_oper.c',
      line: '731',
      routine: 'op_error'
    }
@Yuval-Peled
Copy link

We've also encountered this. This is something that the node.js ecosystem really suffers from, and node.js does not make it easy for library writers in a lot of places.
However, I think this really deserves focus. This is a library that a lot of other libraries depend on, which means that in a lot of cases a DB query error is really hard to debug.

@abenhamdine
Copy link
Contributor

indeed it's a annoying issue
see also #2484 for a previous partly related discussion

@phiresky
Copy link
Contributor

I've made a PR to fix this: #2983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants