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

SNOW-1737830 log the original error with JSON.stringify differently (default doesn't log non-enumerable properties, thus in Error: none) #944

Merged

Conversation

sfc-gh-dszmolka
Copy link
Collaborator

@sfc-gh-dszmolka sfc-gh-dszmolka commented Nov 4, 2024

Description

During investigating #936, it turned out that JSON.stringify-ing the request's error in sf.js unintentionally hides it. Resulting logline:

Encountered an error when sending the request. Details: {}

We're supposed to log the actual full error stack instead.
Tested it and even leaving the circular replacer out and just using the JSON.stringify(err) is not enough, logged error is still empty. When logging the raw err , the object contents get properly logged:

[12:18:59.899 AM]: TypeError: conn.getId is not a function
..
    at options.callback (/opt/nodejs/node_modules/snowflake-sdk/lib/services/sf.js:1333:28)
    at Object.callback (/opt/nodejs/node_modules/snowflake-sdk/lib/services/sf.js:676:43)
    at /opt/nodejs/node_modules/snowflake-sdk/lib/http/base.js:38:24
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  request:

This is what we expect; logging something which actually helps troubleshooting errors instead of {}. However this causes unnecessary splitting of loglines.

Tested with JSON.stringify(err, Object.getOwnPropertyNames(err)) , seems to also fulfill the requirement here, and also can be concatenated into the continuation of the single logline.

{"level":"DEBUG","message":"[3:23:36.016 PM]: Encountered an error when sending the request. Details: {\"stack\":\"TypeError: conn.getId is not a function\\n    at /test/i936.js:37:85\\n    at options.callback (/test/snowflake-connector-nodejs/lib/services/sf.js:1334:28)\\n    at Object.callback (/test/snowflake-connector-nodejs/lib/services/sf.js:677:43)\\n    at /test/snowflake-connector-nodejs/lib/http/base.js:38:24\\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\",\"message\":\"conn.getId is not a function\"}"}

Checklist

  • Format code according to the existing code style (run npm run lint:check -- CHANGED_FILES and fix problems in changed code)
  • Create tests which fail without the change (if possible)
  • Make all tests (unit and integration) pass (npm run test:unit and npm run test:integration)
  • Extend the README / documentation and ensure is properly displayed (if necessary)
  • Provide JIRA issue id (if possible) or GitHub issue id in commit message

@sfc-gh-dszmolka sfc-gh-dszmolka requested a review from a team as a code owner November 4, 2024 14:30
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.88%. Comparing base (d50e1ce) to head (fd5f409).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
lib/connection/connection.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #944      +/-   ##
==========================================
- Coverage   88.93%   88.88%   -0.05%     
==========================================
  Files          69       69              
  Lines        6685     6685              
==========================================
- Hits         5945     5942       -3     
- Misses        740      743       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sfc-gh-dszmolka
Copy link
Collaborator Author

recheck

@sfc-gh-dszmolka
Copy link
Collaborator Author

Jenkins job was actually successful yesterday, just progress is not reported back into github apparently. It's still 'Waiting to run this check..' here.

lib/services/large_result_set.js Outdated Show resolved Hide resolved
lib/services/sf.js Outdated Show resolved Hide resolved
@sfc-gh-dszmolka sfc-gh-dszmolka changed the title SNOW-1737830 log the original error instead of JSON.stringify-ing it SNOW-1737830 log the original error with JSON.stringify differently (default doesn't log non-enumerable properties, thus in Error: none) Nov 12, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka merged commit 48c7740 into master Nov 13, 2024
57 of 59 checks passed
@sfc-gh-dszmolka sfc-gh-dszmolka deleted the SNOW-1737830-some-errors-unexpectedly-not-logged branch November 13, 2024 07:54
@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants