-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fix #42 #43
Merged
Merged
Fix #42 #43
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -303,3 +303,34 @@ test('does not crash when no request connection object', function (t) { | |
res.end() | ||
} | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add a test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
// https://github.com/pinojs/pino-http/issues/42 | ||
test('does not return excessively long object', function (t) { | ||
var dest = split(JSON.parse) | ||
var logger = pinoHttp({ | ||
logger: pino(dest), | ||
serializers: { | ||
req: function (req) { | ||
delete req.connection | ||
return req | ||
} | ||
} | ||
}) | ||
t.plan(1) | ||
|
||
var server = http.createServer(handler) | ||
server.unref() | ||
server.listen(0, () => { | ||
const port = server.address().port | ||
http.get(`http://127.0.0.1:${port}`, () => {}) | ||
}) | ||
|
||
function handler (req, res) { | ||
logger(req, res) | ||
res.end() | ||
} | ||
|
||
dest.on('data', function (obj) { | ||
t.is(Object.keys(obj.req).length, 6) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point I fail to see the point of the symbol
@mcollina - thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gives a free non-enumerable. While writing this I learned:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no sure – but you'd get that without the symbol and the getter/setter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats req.raw for btw... I saw it in the hapi-pino implementation as well - whats the reasoning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah no no wait, you'd need a getter - but you could just return req
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, same thing happens with the getter and setter unless you wrap the object in a function with an enclosed variable to contain the value instead of
set (val) { this._foo = val }
.As for req.raw, see comments hapijs/hapi-pino#34 (comment) and hapijs/hapi-pino#34 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://gist.github.com/jsumners/0a586bf6c3dcb835d692251347a0e730
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha!