Skip to content

Better error messages #172

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

Merged
merged 3 commits into from
Jan 18, 2022
Merged

Better error messages #172

merged 3 commits into from
Jan 18, 2022

Conversation

darora
Copy link
Contributor

@darora darora commented Jan 18, 2022

Both server & client side logs are provided where applicable.

  • if query is not provided

Before (think the server also crashes?):

TypeError: Client was passed a null or undefined query
    at Client.query (/Users/darora/src/supabase/postgres-meta/node_modules/pg/lib/client.js:505:13)
   [...]
[ERROR] 08:01:52 TypeError: Client was passed a null or undefined query
* Empty reply from server
* Closing connection 0
curl: (52) Empty reply from server

After:

{"level":"error","time":"2022-01-18T00:06:44.730Z","pid":77960,"hostname":"Divs-MacBook-Pro.local","error":"Error: query not found","request":{"method":"POST","url":"/query","pg":"localhost"}}
< HTTP/1.1 500 Internal Server Error
< 
* Connection #0 to host localhost left intact{"error":"query not found"}%      

(ideally this would be a 400, but I don't want to undertake a bigger refactoring right now)

  • if connstring can't be processed

Before:

{"statusCode":500,"error":"Internal Server Error","message":"Cannot read property 'charAt' of undefined"}% 

After:

{"level":"warn","time":"2022-01-18T00:11:20.915Z","pid":85773,"hostname":"Divs-MacBook-Pro.local","reqId":"req-1","message":"failed to parse encrypted connstring","error":"Error: Malformed UTF-8 data"}
{"level":"error","time":"2022-01-18T00:11:20.915Z","pid":85773,"hostname":"Divs-MacBook-Pro.local","error":"Error: failed to process upstream connection details","request":{"method":"POST","url":"/query","pg":"unknown"}}
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
* Connection #0 to host localhost left intact
{"error":"failed to process upstream connection details"}%

- emit a string level rather than numeric (i.e. 'error' instead of 50)
- emit a readable ISO8601 timestamp instead of unix epoch time
@darora darora requested review from soedirgo and kiwicopple January 18, 2022 00:22
Base automatically changed from da/misc-fixes to master January 18, 2022 03:45
@soedirgo soedirgo merged commit 9da6ae6 into master Jan 18, 2022
@soedirgo soedirgo deleted the da/cleaner-error-messages branch January 18, 2022 03:47
@github-actions
Copy link

🎉 This PR is included in version 0.31.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

avallete pushed a commit that referenced this pull request May 13, 2025
* chore: cleaner logging output

- emit a string level rather than numeric (i.e. 'error' instead of 50)
- emit a readable ISO8601 timestamp instead of unix epoch time

* chore: better request logging when pg header is absent or malformed

* chore: better error message if query is not provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants