-
-
Notifications
You must be signed in to change notification settings - Fork 34k
tests: fix inspector uri-encoded paths #59991
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
Open
kapouer
wants to merge
1
commit into
nodejs:main
Choose a base branch
from
kapouer:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| 'use strict'; | ||
| const common = require('../common'); | ||
|
|
||
| common.skipIfInspectorDisabled(); | ||
|
|
||
| const assert = require('assert'); | ||
| const { Session } = require('inspector'); | ||
| const path = require('path'); | ||
| const { pathToFileURL } = require('url'); | ||
|
|
||
| function debugged() { | ||
| return 42; | ||
| } | ||
|
|
||
| async function test() { | ||
| // Check without properly decoding | ||
| const session1 = new Session(); | ||
| session1.connect(); | ||
| let session1Paused = false; | ||
| session1.on('Debugger.paused', () => session1Paused = true); | ||
| session1.post('Debugger.enable'); | ||
|
|
||
| await new Promise((resolve, reject) => { | ||
| session1.post('Debugger.setBreakpointByUrl', { | ||
| 'lineNumber': 12, | ||
| 'url': pathToFileURL(path.resolve(__dirname, __filename)).toString(), | ||
| 'columnNumber': 0, | ||
| 'condition': '' | ||
| }, (error, result) => { | ||
| return error ? reject(error) : resolve(result); | ||
| }); | ||
| }); | ||
|
|
||
| debugged(); | ||
|
|
||
| assert(!session1Paused); | ||
| session1.disconnect(); | ||
|
|
||
| // Check correctly with another session | ||
| let session2Paused = false; | ||
| const session2 = new Session(); | ||
| session2.connect(); | ||
| session2.on('Debugger.paused', () => session2Paused = true); | ||
| session2.post('Debugger.enable'); | ||
|
|
||
| await new Promise((resolve, reject) => { | ||
| session2.post('Debugger.setBreakpointByUrl', { | ||
| 'lineNumber': 12, | ||
| 'url': decodeURIComponent(pathToFileURL(path.resolve(__dirname, __filename)).toString()), | ||
| 'columnNumber': 0, | ||
| 'condition': '' | ||
| }, (error, result) => { | ||
| return error ? reject(error) : resolve(result); | ||
| }); | ||
| }); | ||
|
|
||
| debugged(); | ||
|
|
||
| assert(session2Paused); | ||
| session2.disconnect(); | ||
| } | ||
|
|
||
| const interval = setInterval(() => {}, 1000); | ||
| test().then(common.mustCall(() => { | ||
| clearInterval(interval); | ||
| console.log('Done!'); | ||
| })); |
Oops, something went wrong.
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.
I don't think this is correct. The field
urlhas to be a string in correct URL format.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 agree - I totally failed to fix this. I spent hours on this trying to find the root cause, no success.
My plan is to ignore that bug :(
Uh oh!
There was an error while loading. Please reload this page.
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.
@legendecas It seems that the inspector server can't resolve the file and fails to set breakpoints when the
urlhas encoded values. Decoding the url by the client looks a valid workaround to me. What do you think?Decoded URL
Encoded URL
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.
Note that there is already logic implemented to percent-encode special characters.
It's even tested by one of node's CI.
However, it fails for ~ (and + maybe), and this PR means nothing until it understands why.
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.
Can you point it out?
Uh oh!
There was an error while loading. Please reload this page.
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 ! I only know there is a test about it, and that test doesn't include ~ + chars
node/.github/workflows/test-linux.yml
Lines 72 to 78 in 3dba25f
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's an interesting point. The filename including
?can work fine.