GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — worker: support relative paths by itaysabato · Pull Request #21407 · nodejs/node Conversation
|
|
The catch here is that this may lead to surprising results if the program is run from a different working directory than what is expected. If we do support relative paths, I’d much prefer it if we could make it relative to the path of the caller script… |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @addaleax I find that it would be very counter-intuitive for the path to be relative to the caller script. For instance, if I call |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I would expect |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think changing it would require just resolving with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Fair point @benjamingr. I tend to agree, though that would mean Is that what you're going for?
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Come to think of it, I would say Also, I really don't know how to get the caller file path without hacking into the stack trace or something like that. It is a bit weird to expect a constructor to "know" which file his caller comes from. For an import statement (and |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@itaysabato so the current (non process.cwd) behaviour is similar to how |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I was explicitly referring to the CWD behaviour - although you can |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The thing is, this being the majority use case makes it easy to write code under that assumption… As you noticed, I’m not putting a red X on this or anything. I’m saying that this was a choice I made and that, if other people think it makes sense, I’m okay with it being aligned with somebody else’s expectations rather than mine. :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I'm not sure why you call it "non process.cwd" because the current code calls I didn't know |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Relative to cwd is what I expect. It is also closer to how Web Workers do it imo
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
One possible concern that I realized today: If we work towards full web compat, then allowing relative paths is going to conflict with URL strings and I think we’d need to either undo this or control it through the options object here. :/ Maybe we could use |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Can you explain this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@benjamingr One pain point we’ve had with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@addaleax I'm -1 on accepting URL strings to worker - I'm +1 on accepting URL objects at some point in the future though though some people (namely @issacs) have objected to this due to the burden on third-party authors and security implications. Then again unlike file-reading I really don't see dynamic worker URLs as something too common. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What about throwing for now if a valid URL is passed? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
That seems like it would be at odds with ever making |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@addaleax what if instead of opting in for relative paths users would opt in for urls? E.g. Does that make sense? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Going to do one last ping to @devsnek to make sure they are OK with the behavior and land it tomorrow if there are no objections. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@itaysabato That makes sense if we don’t expect URL usage by default / don’t care about the fact that WebWorkers use URLs … my gut feeling is still that we would rather want to put relative paths behind an option, but I can see valid points for either side here :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@addaleax if you really think supporting plain relative paths might conflict with URL strings then I agree this is a serious concern indeed. I thought that was only the case for fs because of how entrenched the workflows are, and would have assumed that such a brutal edge case wouldn't need to apply here for backwards compatibility concerns in future. But if it is a concern, then this could be restricted to only an absolute or relative path (starting with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Another way to postpone the URL support decision is to only support relative paths starting with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I do think it's important to ensure the best outcome for URL compatibility here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we can add the filter here to only apply path.resolve for absolute, ./ and ../ paths.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
On it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
why the nextTick here? Seems a bit pointless.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actually it was simply copied from test-worker.js
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For context, inside that test the purpose is to make sure that both libuv bindings + process.nextTick() work – we don’t need that here, and I probably should have added a comment to the other test about it ;)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I can't tell from the build logs what's wrong. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
CI failures seem unrelated |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
9348fe0 to
8defed3
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell this isn't system aware hence the CI failures. Feel free to dismiss my objection if I'm incorrect.
The explicit test for './' and '../' seems to point in that direction though...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@apapirovski as far as I can see the build is passing now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@itaysabato The last CI I can see is red and certainly had related failures. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ah I see, so the Travis build doesn't cover everything Jenkins covers? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Travis only covers linting and testing on Linux.
No. A collaborator has to manually trigger a Jenkins run. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Finally managed to build on a windows vm. ***fixing... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This commit adds support for relative paths in Worker. Paths are relative to the current working directory. PR-URL: nodejs#21407 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
ca338a3 to
c31ae12
Compare
|
Should be fixed now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sure :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
thanks :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This commit adds support for relative paths in Worker. Paths are relative to the current working directory. PR-URL: #21407 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
There was an error while loading. Please reload this page.
|
CI is now green, good catch Anatoli and thanks for fixing Itay! Landed in 8d33bbf 🎉 I hope this is your first PR in many! Random nit - PR-URL should be a URL :) I amended that for you. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This commit adds support for relative paths in Worker. Paths are relative to the current working directory. PR-URL: #21407 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Notable changes:
* build:
* Node.js should now be about 60% faster to startup than the previous version,
thanks to the use V8's code cache feature for core modules. [#21405](#21405)
* dns:
* An experimental promisified version of the dns module is now available. Give
it a try with `require('dns').promises`. [#21264](#21264)
* fs:
* `fs.lchown` has been undeprecated now that libuv supports it. [#21498](#21498)
* lib:
* `Atomics.wake` is being renamed to `Atomics.notify` in the ECMAScript
specification ([reference](tc39/ecma262#1220)).
Since Node.js now has experimental support for worker threads, we are being
proactive and added a `notify` alias, while emitting a warning if
`wake` is used. [#21413](#21413) [#21518](#21518)
* n-api:
* Add API for asynchronous functions. [#17887](#17887)
* util:
* `util.inspect` is now able to return a result instead of throwing when the
maximum call stack size is exceeded during inspection. [#20725](#20725)
* vm:
* Add `script.createCachedData()`. This API replaces the `produceCachedData`
option of the `Script` constructor that is now deprecated. [#20300](#20300)
* worker:
* Support for relative paths has been added to the `Worker` constructor. Paths
are interpreted relative to the current working directory. [#21407](#21407)
PR-URL: #21629
Notable changes:
* dns:
* An experimental promisified version of the dns module is now available. Give
it a try with `require('dns').promises`. [#21264](#21264)
* fs:
* `fs.lchown` has been undeprecated now that libuv supports it. [#21498](#21498)
* lib:
* `Atomics.wake` is being renamed to `Atomics.notify` in the ECMAScript
specification ([reference](tc39/ecma262#1220)).
Since Node.js now has experimental support for worker threads, we are being
proactive and added a `notify` alias, while emitting a warning if
`wake` is used. [#21413](#21413) [#21518](#21518)
* n-api:
* Add API for asynchronous functions. [#17887](#17887)
* util:
* `util.inspect` is now able to return a result instead of throwing when the
maximum call stack size is exceeded during inspection. [#20725](#20725)
* vm:
* Add `script.createCachedData()`. This API replaces the `produceCachedData`
option of the `Script` constructor that is now deprecated. [#20300](#20300)
* worker:
* Support for relative paths has been added to the `Worker` constructor. Paths
are interpreted relative to the current working directory. [#21407](#21407)
PR-URL: #21629
Notable changes:
* dns:
* An experimental promisified version of the dns module is now available. Give
it a try with `require('dns').promises`. [#21264](#21264)
* fs:
* `fs.lchown` has been undeprecated now that libuv supports it. [#21498](#21498)
* lib:
* `Atomics.wake` is being renamed to `Atomics.notify` in the ECMAScript
specification ([reference](tc39/ecma262#1220)).
Since Node.js now has experimental support for worker threads, we are being
proactive and added a `notify` alias, while emitting a warning if
`wake` is used. [#21413](#21413) [#21518](#21518)
* n-api:
* Add API for asynchronous functions. [#17887](#17887)
* util:
* `util.inspect` is now able to return a result instead of throwing when the
maximum call stack size is exceeded during inspection. [#20725](#20725)
* vm:
* Add `script.createCachedData()`. This API replaces the `produceCachedData`
option of the `Script` constructor that is now deprecated. [#20300](#20300)
* worker:
* Support for relative paths has been added to the `Worker` constructor. Paths
are interpreted relative to the current working directory. [#21407](#21407)
PR-URL: #21629
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.