GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: don't print garbage errors by cjihrig · Pull Request #4112 · nodejs/node

Conversation

@cjihrig

@cjihrig cjihrig commented Dec 2, 2015

Copy link
Copy Markdown
Contributor

If JS throws an object whose toString() method throws, then Node attempts to print an empty message, but actually prints garbage. This commit checks for this case, and prints a newline instead.

Closes #4079

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mscdex mscdex added the c++ Issues and PRs that require attention from people who are familiar with C++. label Dec 2, 2015
@chrisdickinson

chrisdickinson commented Dec 2, 2015

Copy link
Copy Markdown
Contributor

LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed Dec 2, 2015
View reviewed changes
Comment thread src/node.cc Outdated

@bnoordhuis bnoordhuis Dec 2, 2015

Copy link
Copy Markdown
Member

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.

You could simplify this to PrintErrorString("%s\n", *message ? *message : "");

I would print a message like "<toString() threw exception>" instead of a blank line.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cjihrig cjihrig Dec 2, 2015

Copy link
Copy Markdown
Contributor Author

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.

I would print a message like "<toString() threw exception>" instead of a blank line.

I thought about that, but the current check is insufficient, since empty string is a valid toString() response. Would you be OK with me using a TryCatch to actually detect if an error was thrown?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bnoordhuis bnoordhuis Dec 3, 2015

Copy link
Copy Markdown
Member

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.

I mean when *message == nullptr, that means .toString() failed somehow.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cjihrig cjihrig Dec 3, 2015

Copy link
Copy Markdown
Contributor Author

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.

That doesn't seem to be the case though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cjihrig cjihrig Dec 3, 2015

Copy link
Copy Markdown
Contributor Author

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.

@bnoordhuis is *message == nullptr for you? If so, it might be platform specific based on #4079 (comment).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bnoordhuis bnoordhuis Dec 5, 2015

Copy link
Copy Markdown
Member

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, I missed that it's using node::Utf8Value (which indeed never returns a nullptr because it returns a pointer to its embedded char array.)

If you use String::Utf8Value, you should see *message == nullptr after a .toString() exception.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jasnell

jasnell commented Dec 3, 2015

Copy link
Copy Markdown
Member

LGTM once @bnoordhuis is happy with it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Dec 3, 2015

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell added the lts-watch-v4.x label Dec 3, 2015
@JungMinu

JungMinu commented Dec 4, 2015

Copy link
Copy Markdown
Member

CI : https://ci.nodejs.org/job/node-test-pull-request/922/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JungMinu

JungMinu commented Dec 4, 2015

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JungMinu

JungMinu commented Dec 4, 2015

Copy link
Copy Markdown
Member

Would you mind if I land this PR? 😄

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Dec 4, 2015

Copy link
Copy Markdown
Contributor Author

@JungMinu Don't land it yet, as the test fails on Windows.

I'd also like @bnoordhuis's input. message alone, at least on OS X, doesn't seem to provide enough information to differentiate between a toString() error, and a valid empty string result. Do you think it's worth using a TryCatch to differentiate between the two? I've implemented it, and it seems very straightforward.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JungMinu

JungMinu commented Dec 5, 2015

Copy link
Copy Markdown
Member

@cjihrig Sorry to bug you, It slipped my mind. 😢

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JungMinu

JungMinu commented Dec 5, 2015

Copy link
Copy Markdown
Member

IMHO, I think that using a TryCatch to differentiate between the two is fine :)
(I guess that I saw some similar cases in code base before)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig
src: don't print garbage errors
3b27beb
If JS throws an object whose toString() method throws, then Node
attempts to print an empty message, but actually prints garbage.
This commit checks for this case, and prints a message instead.
@cjihrig
cjihrig force-pushed the 4079 branch from b4b4fe2 to 3b27beb Compare December 5, 2015 15:21
@cjihrig

cjihrig commented Dec 5, 2015

Copy link
Copy Markdown
Contributor Author

New CI: https://ci.nodejs.org/job/node-test-pull-request/931/

Made the change to String::Utf8Value. @bnoordhuis still LGTY?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Dec 5, 2015

Copy link
Copy Markdown
Contributor Author

CI failures are unrelated.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Dec 5, 2015

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig added a commit that referenced this pull request Dec 5, 2015
@cjihrig
src: don't print garbage errors
1ec09b0
If JS throws an object whose toString() method throws, then Node
attempts to print an empty message, but actually prints garbage.
This commit checks for this case, and prints a message instead.

Fixes: #4079
PR-URL: #4112
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
@cjihrig

cjihrig commented Dec 5, 2015

Copy link
Copy Markdown
Contributor Author

Thanks, landed in 1ec09b0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig cjihrig closed this Dec 5, 2015
@cjihrig
cjihrig deleted the 4079 branch December 5, 2015 16:16
cjihrig added a commit that referenced this pull request Dec 8, 2015
@cjihrig @rvagg
src: don't print garbage errors
da3137d
If JS throws an object whose toString() method throws, then Node
attempts to print an empty message, but actually prints garbage.
This commit checks for this case, and prints a message instead.

Fixes: #4079
PR-URL: #4112
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
@rvagg rvagg mentioned this pull request Dec 8, 2015
Release proposal: v5.2.0 (Stable) #4181
Merged
@rvagg rvagg mentioned this pull request Dec 17, 2015
Release 4.2.4 Planning #4321
Closed
cjihrig added a commit that referenced this pull request Dec 29, 2015
@cjihrig Myles Borins
src: don't print garbage errors
6c2cb45
If JS throws an object whose toString() method throws, then Node
attempts to print an empty message, but actually prints garbage.
This commit checks for this case, and prints a message instead.

Fixes: #4079
PR-URL: #4112
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
@MylesBorins MylesBorins added land-on-v4.x and removed lts-watch-v4.x labels Dec 29, 2015
MylesBorins pushed a commit that referenced this pull request Jan 19, 2016
@cjihrig Myles Borins
src: don't print garbage errors
c96eca1
If JS throws an object whose toString() method throws, then Node
attempts to print an empty message, but actually prints garbage.
This commit checks for this case, and prints a message instead.

Fixes: #4079
PR-URL: #4112
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jan 19, 2016
V4.2.5 proposal #4768
Merged
This was referenced Dec 7, 2023
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1144
Open
[Snyk] Security upgrade mocha from 6.2.0 to 8.3.0 aliscco/alisco-node#1145
Open
This was referenced Dec 7, 2023
[Snyk] Security upgrade mocha from 7.1.1 to 8.3.0 leonardoadame/node#563
Open
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 leonardoadame/node#566
Open
@baby636 baby636 mentioned this pull request Dec 7, 2023
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 baby636/node#120
Open
This was referenced Dec 7, 2023
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1147
Open
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 aliscco/alisco-node#1148
Open
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1149
Open
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1150
Open
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 aliscco/alisco-node#1151
Open
[Snyk] Security upgrade mocha from 6.2.0 to 8.3.0 aliscco/alisco-node#1152
Open
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 aliscco/alisco-node#1153
Open
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1154
Open
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1155
Open
This was referenced Dec 8, 2023
[Snyk] Fix for 1 vulnerabilities leonardoadame/node#567
Open
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 leonardoadame/node#569
Open
@aliscco aliscco mentioned this pull request Dec 8, 2023
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 aliscco/alisco-node#1157
Open
This was referenced Dec 8, 2023
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 leonardoadame/node#570
Open
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 leonardoadame/node#571
Open
@aliscco aliscco mentioned this pull request Dec 8, 2023
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 aliscco/alisco-node#1160
Open
@leonardoadame leonardoadame mentioned this pull request Dec 8, 2023
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 leonardoadame/node#572
Open
This was referenced Dec 8, 2023
[Snyk] Security upgrade mocha from 7.2.0 to 8.3.0 aliscco/alisco-node#1162
Open
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1163
Open
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 aliscco/alisco-node#1164
Open
@adamlaska adamlaska mentioned this pull request Dec 8, 2023
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 adamlaska/node#134
Open
@leonardoadame leonardoadame mentioned this pull request Dec 8, 2023
[Snyk] Security upgrade mocha from 6.2.3 to 8.3.0 leonardoadame/node#574
Open
EhabY added a commit to coder/vscode-coder that referenced this pull request Apr 30, 2026
@EhabY
fix(cliExec): refresh credentials per CLI call instead of env-forwarding
185abc4
Forwarding CODER_SESSION_TOKEN via the child env exposed it to any
sibling process via /proc/<pid>/environ on Linux and similar interfaces
elsewhere. Drop all env injection from cliExec and instead refresh the
file or keyring once via cliManager.configure inside resolveCliEnv,
mirroring the connection-time write in remote.ts. The CLI reads the
fresh token from the file (or keyring on supported systems) via the
existing --global-config / --url flags. mTLS still works since the
refresh accepts an empty token.

Also drop the keyringOnly option from storeToken (no longer needed now
that we always refresh) and update the matching tests.

Add writeStdoutJs / writeStderrJs helpers in test/utils/platform.ts that
generate fs.writeSync snippets, and use them in the cliExec and platform
tests. process.stdout/stderr.write is async on POSIX pipes and can be
lost on exit (nodejs/node#4112), which was making the version fallback
test flaky.
@EhabY EhabY mentioned this pull request Apr 30, 2026
fix: refresh CLI credentials before each invocation coder/vscode-coder#926
Merged
EhabY added a commit to coder/vscode-coder that referenced this pull request Apr 30, 2026
@EhabY
fix(cliExec): refresh credentials per CLI call instead of env-forwarding
0ca0170
Forwarding CODER_SESSION_TOKEN via the child env exposed it to any
sibling process via /proc/<pid>/environ on Linux and similar interfaces
elsewhere. Drop all env injection from cliExec and instead refresh the
file or keyring once via cliManager.configure inside resolveCliEnv,
mirroring the connection-time write in remote.ts. The CLI reads the
fresh token from the file (or keyring on supported systems) via the
existing --global-config / --url flags. mTLS still works since the
refresh accepts an empty token.

Also drop the keyringOnly option from storeToken (no longer needed now
that we always refresh) and update the matching tests.

Add writeStdoutJs / writeStderrJs helpers in test/utils/platform.ts that
generate fs.writeSync snippets, and use them in the cliExec and platform
tests. process.stdout/stderr.write is async on POSIX pipes and can be
lost on exit (nodejs/node#4112), which was making the version fallback
test flaky.
EhabY added a commit to coder/vscode-coder that referenced this pull request Apr 30, 2026
@EhabY
fix(cliExec): refresh credentials per CLI call instead of env-forwarding
c104424
Forwarding CODER_SESSION_TOKEN via the child env exposed it to any
sibling process via /proc/<pid>/environ on Linux and similar interfaces
elsewhere. Drop all env injection from cliExec and instead refresh the
file or keyring once via cliManager.configure inside resolveCliEnv,
mirroring the connection-time write in remote.ts. The CLI reads the
fresh token from the file (or keyring on supported systems) via the
existing --global-config / --url flags. mTLS still works since the
refresh accepts an empty token.

Also drop the keyringOnly option from storeToken (no longer needed now
that we always refresh) and update the matching tests.

Add writeStdoutJs / writeStderrJs helpers in test/utils/platform.ts that
generate fs.writeSync snippets, and use them in the cliExec and platform
tests. process.stdout/stderr.write is async on POSIX pipes and can be
lost on exit (nodejs/node#4112), which was making the version fallback
test flaky.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@cjihrig @chrisdickinson @jasnell @bnoordhuis @JungMinu @mscdex @MylesBorins
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.