Skip to content

fix: add null check for connection.headers - #2200

Merged
hiroppy merged 2 commits into
webpack:masterfrom
wood1986:fix-2199
Aug 20, 2019
Merged

fix: add null check for connection.headers#2200
hiroppy merged 2 commits into
webpack:masterfrom
wood1986:fix-2199

Conversation

@wood1986

@wood1986wood1986 commented Aug 16, 2019

Copy link
Copy Markdown
Contributor

fix#2199

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Motivation / Use-Case

Breaking Changes

Additional Info

@jsf-clabot

jsf-clabot commented Aug 16, 2019

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecovBot commented Aug 16, 2019

Copy link
Copy Markdown

Codecov Report

Merging #2200 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@## master #2200 +/- ##
=======================================
Coverage 93.91% 93.91% =======================================
Files 34 34 Lines 1282 1282 Branches 370 371 +1 =======================================
Hits 1204 1204 Misses 71 71 Partials 7 7
Impacted FilesCoverage Δ
lib/servers/SockJSServer.js93.75% <100%> (ø)⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bcacacf...dca0f81. Read the comment docs.

@wood1986
wood1986force-pushed the fix-2199 branch 2 times, most recently from d602201 to 1d05d6cCompareAugust 16, 2019 05:02
@alexander-akait

Copy link
Copy Markdown
Member

/cc @Loonride

@alexander-akaitalexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need tests

@knagaitsev

Copy link
Copy Markdown
Contributor

If the connection object is null, there is no use in passing it along to the callback since we can't do anything with it. I think it is better off being:

if (connection) {
f(connection, connection.headers);
}

@wood1986

Copy link
Copy Markdown
ContributorAuthor

If the connection object is null, there is no use in passing it along to the callback since we can't do anything with it. I think it is better off being:

if (connection) {
f(connection, connection.headers);
}

I thought about this. As you have a check in

this.socketServer.onConnection((connection,headers)=>{
if(!connection){
return;
}
if(!headers){
this.log.warn(
'transportMode.server implementation must pass headers to the callback of onConnection(f) '+
'via f(connection, headers) in order for clients to pass a headers security check'
);
}

I want to reuse.

@wood1986wood1986 changed the title fix: Cannot read property 'headers' of null at Server.socket.onfix: add null check for connection.headersAug 17, 2019
@wood1986

Copy link
Copy Markdown
ContributorAuthor

need tests

I added

@wood1986

Copy link
Copy Markdown
ContributorAuthor

Any updates?

Comment threadtest/server/servers/SockJSServer.test.js Outdated
Comment threadtest/server/servers/SockJSServer.test.js Outdated
Comment threadtest/server/servers/SockJSServer.test.js
@knagaitsev

Copy link
Copy Markdown
Contributor

I want to reuse.

Understood. I have added some notes on the tests.

Comment threadtest/server/servers/SockJSServer.test.js Outdated
@knagaitsev

Copy link
Copy Markdown
Contributor

Looks good to me /cc @evilebottnawi@hiroppy

@alexander-akaitalexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hiroppy
hiroppy merged commit 7964997 into webpack:masterAug 20, 2019
@wood1986

Copy link
Copy Markdown
ContributorAuthor

When will you guys do the npm publish?

@Sleepful

Copy link
Copy Markdown

@wood1986 not yet I guess, you can use the master branch on your package.json for now if you want:

"webpack-dev-server": "git+https://github.com/webpack/webpack-dev-server.git"

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read property 'headers' of null at Server.socket.on (***/node_modules/webpack-dev-server/lib/servers/SockJSServer.js:68:32)

7 participants

@wood1986@jsf-clabot@alexander-akait@knagaitsev@Sleepful@hiroppy@evilebottnawi