-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: add sockPath
option (options.sockPath
)
#1553
feat: add sockPath
option (options.sockPath
)
#1553
Conversation
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.
Looks good, need add tests
sockPath
option (options.sockPath
)
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.
@trescenzi Thx in advance
@@ -0,0 +1,15 @@ | |||
# Node.js API - Simple |
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.
Please remove all examples
as we don't intend to maintain them in the future (#1469)
@@ -2,7 +2,7 @@ | |||
|
|||
/* global __resourceQuery WorkerGlobalScope self */ | |||
/* eslint prefer-destructuring: off */ | |||
|
|||
const querystring = require('querystring'); |
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.
const querystring = require('querystring'); | |
const qs = require('querystring'); |
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.
Disagree, no need rewrite full package name to short name.
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.
qs
also conflicts with another variable in the file, and eslint complains about shadowing. That's why it's been renamed from the original PR.
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.
@trescenzi you did everything right, do not rename
@@ -321,6 +324,7 @@ | |||
"filename": "should be {String|RegExp|Function} (https://webpack.js.org/configuration/dev-server/#devserver-filename-)", | |||
"port": "should be {String|Number} (https://webpack.js.org/configuration/dev-server/#devserver-port)", | |||
"socket": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-socket)", | |||
"sockPath": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-sockPath)", |
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.
This needs to be documented by opening a PR in docs repo please. Currently to URL redirects to the dev server 'landing page', which might be confusing for some and ultimately isn't really helpful
Codecov Report
@@ Coverage Diff @@
## master #1553 +/- ##
==========================================
+ Coverage 74.41% 74.49% +0.07%
==========================================
Files 10 10
Lines 688 690 +2
==========================================
+ Hits 512 514 +2
Misses 176 176
Continue to review full report at Codecov.
|
I've:
Still need to update the webpack documentation itself with another PR. Let me know if there's more to do here. Also do you want these commits squashed or are they ok as is? |
8351dd0
to
bd31f5a
Compare
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.
Looks good, let's wait CI green, after merge need create PR in webpack docs repo
Huh so I was running the tests with a |
The test issues are only in |
@trescenzi can you reproducible test failed locally? |
@evilebottnawi I can reproduce the hanging CLI tests locally. I'm busy over the next few days but I can take a look again on monday. |
@trescenzi can you provide details how you can reproduce problem? |
@evilebottnawi all I have to do, on master, is:
Sometimes it hangs during the tests, sometimes it segfaults. I don't have issues with node 10.12.0. |
@trescenzi thanks! |
My apologies I've been away from this for so long. I've got time over the next few days to figure out what's up and get this out. |
@trescenzi If you rebase to newest master, Node 11 is disabled for now. I did see one hang on Node 10 too, but I don't run Mac OS X, so it was hard to debug. I've opened a bug on node.js, if you potentially want to try this with |
When I was trying to get the tests working before I made so updates to the tests for this change that used supertest more idiomatically instead of relying upon @odinho definitely interested in debugging node. It's been too long since I've attached gdb to a running process haha. Not sure if I have time this moment to do so though. I'll see when I end up today. The issues are still 100% reproducible in the tests just by switching to node 11. |
5a05b5e
to
a3d320e
Compare
Any updates here? As far as I'm aware it should be good to merge. Let me know if there's anything else I can do. |
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.
Just couple questions and we can merge
@@ -85,6 +85,7 @@ function Server (compiler, options = {}, _log) { | |||
|
|||
this.watchOptions = options.watchOptions || {}; | |||
this.contentBaseWatchers = []; | |||
this.sockPath = `/${options.sockPath ? options.sockPath.replace(/^\/|\/$/g, '') : 'sockjs-node'}`; |
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.
Why we need .replace(/^\/|\/$/g, '')
?
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.
So this is largely to allow users to provide either: sockPath: '/this/is/a/path/'
or sockPath: 'this/is/a/path'
and have it behave the same way.
The leading slash gets added by this template string. Instead of checking if there's a leading slash and only adding one if there isn't one, this just always adds a leading slash and removes any if there is one.
The trailing slash is removed because it doesn't mean anything in this case and is likely a result of user error.
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.
@trescenzi please add comment to code with this information in concise form, thanks
@@ -196,7 +196,7 @@ const socketUrl = url.format({ | |||
auth: urlParts.auth, | |||
hostname, | |||
port: urlParts.port, | |||
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : urlParts.path | |||
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : (querystring.parse(urlParts.path).sockPath || urlParts.path) |
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.
Why we need use querystring.parse
here?
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 I don't know the answer to. It was left over from the initial pr and I kinda just assumed was how stuff was done. Will investigate and come back with an answer.
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.
@trescenzi thanks!
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.
So what's happening here is that __resouceQuery
gets the sockPath
option passed in. This is then parsing that querystring and getting the sockPath
option.
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.
@trescenzi just add this comment to code 👍
While waiting for this, I came up with a temporary workaround (assuming you are using webpack). You'll need the file in this gist: https://gist.github.com/zsalzbank/cdee4f852e4a89c116eb7a28491bbf63 Then, add the exported plugin to your babel plugins like so: ...
plugins: [
require('sockjs-prefix-modification')('/my-prefix-path/').plugin
],
... And before you import require('sockjs-prefix-modification')('/my-prefix-path/').fixWebpackDevServer(); You'll need |
/cc @trescenzi can you fix note from me above and we can merge |
My apologies for taking forever to update this. It dropped off my radar. It should be good now. I'm going to put up a PR against the docs site now. |
Looks like the linting hung? It lints fine for me locally. |
@trescenzi yep, something wrong with travis ci, rerun CI |
This is a version of #1289 that's up to date with master.
For Bugs and Features; did you add new tests?
The tests that were added in #1289 seem to exist in master now. I can add more specific tests if desired.
Motivation / Use-Case
copied from #1289; although I have the same motivation
Similar motivations as #911.
We also have multiple apps being developed behind a reverse proxy (in our case a docker composed nginx). Each app is served from a top-level sub-directory (can't use root path), e.g. host/app-part-one, host/app-another-piece
Breaking Changes
None
Additional Info
There was discussion on #1289 about adding
port
andhost
to the socks options. I'm happy to do so if there's still interest. I didn't include it here though because this happens to be all I need.