Skip to content
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

flaky tests #682

Closed
ronag opened this issue Apr 6, 2021 · 12 comments
Closed

flaky tests #682

ronag opened this issue Apr 6, 2021 · 12 comments
Labels
bug Something isn't working
Milestone

Comments

@ronag
Copy link
Member

ronag commented Apr 6, 2021

FAIL  test/client.js
 ✖ (unnamed test)

  test/client.js                                          
  517 |       body                                        
  518 |     }, (err, { statusCode, headers, body }) => {  
> 519 |       t.error(err)                                
      | --------^                                         
  520 |       body                                        
  521 |         .on('data', () => {                       
  522 |           t.fail()                                

  test: test/client.js basic POST with empty stream
  stack: |
    test/client.js:519:9
    lib/api/api-request.js:132:14

  Error Origin:

  lib/llhttp/parser.js                                                                      
  187 |       const message = Buffer.from(inst.exports.memory.buffer, ptr, len).toString()  
  188 |       const code = constants.ERROR[err]                                             
> 189 |       return new HTTPParserError(message, code)                                     
      | -------------^                                                                      
  190 |     }                                                                               
  191 |   }                                                                                 
  192 | }                                                                                   

  stack: |
    Parser.execute (lib/llhttp/parser.js:189:14)
    Socket.onSocketData (lib/client.js:807:29)
  type: HTTPParserError
  code: HPE_INVALID_CONSTANT
  message: "HTTPParserError: "

 FAIL  test/client.js
 ✖ Cannot read property 'on' of undefined

  test/client.js                     
  519 |       t.error(err)           
  520 |       body                   
> 521 |         .on('data', () => {  
      | ---------^                   
  522 |           t.fail()           
  523 |         })                   
  524 |         .on('end', () => {   

  test: basic POST with empty stream
  stack: |
    test/client.js:521:10
    lib/api/api-request.js:132:14
  type: TypeError
  tapCaught: uncaughtException

@ronag ronag added the bug Something isn't working label Apr 6, 2021
@ronag ronag added this to the 4.0 milestone Apr 6, 2021
@ronag ronag closed this as completed Apr 6, 2021
@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

Can't repro anymore.

@ronag ronag changed the title flaky test flaky tests Apr 6, 2021
@ronag ronag reopened this Apr 6, 2021
@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

Another flaky test:

 FAIL  test/redirect-request.js
  should be equal


  t.equal(statusCode, 200)
----^
  t.notOk(headers.location)
  /*

  --- expected    
  +++ actual      
  @@ -1,1 +1,1 @@ 
  -200            
  +426            

  test: test/redirect-request.js should follow redirections when going cross origin
  at:
    line: 293
    column: 5
    file: test/redirect-request.js
    type: Test
  stack: |
    Test.<anonymous> (test/redirect-request.js:293:5)

 FAIL  test/redirect-request.js
 ✖ should be equal

  */
  t.equal(body, 'POST')
----^
})

  --- expected      
  +++ actual        
  @@ -1,1 +1,1 @@   
  -POST             
  +Upgrade Required 

  test: test/redirect-request.js should follow redirections when going cross origin
  at:
    line: 306
    column: 5
    file: test/redirect-request.js
    type: Test
  stack: |
    Test.<anonymous> (test/redirect-request.js:306:5)

@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

@dnlup see The above error, looks a bit like a parser error. The status message (Upgrade Required) somehow ended up in the message body.

@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

Strangely it has only happened once so far... there seems to be some kind of interference between requests (parallel test runs?) and the WASM module.

Do we have any global state other than currentParser that might be causing issues?

Do we need to load a separate instance of the WASM module for each client instance?

@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

In wasm_on_header_field, wasm_on_header_value and wasm_on_body. Is at relative to the global buffer inst.exports.memory.buffer or the instance buffer inst.exports.memory.buffer + this[kPtr]?

@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

Feels related to #659. Do we have some form of state corruption somewhere?

@dnlup
Copy link
Contributor

dnlup commented Apr 6, 2021

@dnlup see The above error, looks a bit like a parser error. The status message (Upgrade Required) somehow ended up in the message body.

There are some parser error indeed. This the first time I see them though🤔.

@dnlup
Copy link
Contributor

dnlup commented Apr 6, 2021

Strangely it has only happened once so far... there seems to be some kind of interference between requests (parallel test runs?) and the WASM module.

Do we have any global state other than currentParser that might be causing issues?

Do we need to load a separate instance of the WASM module for each client instance?

I'll check about the global state, before we had the Map to keep track of instances, but I doubt that's the problem. I'll see if loading different instances can bring some benefits.

@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

Another one:

 FAIL  test/abort-controller.js
 ✖ should be equal

  test/abort-controller.js                                               
  65 |         })                                                        
  66 |         response.body.on('end', () => {                           
> 67 |           t.equal('hello', Buffer.concat(bufs).toString('utf8'))  
     | ------------^                                                     
  68 |         })                                                        
  69 |       })                                                          
  70 |                                                                   

  --- expected      
  +++ actual        
  @@ -1,1 +1,1 @@   
  -Upgrade Required 
  +hello            

  test: test/abort-controller.js Abort native-abortcontroller before sending
    request (no body)
  stack: |
    RequestResponse.<anonymous> (test/abort-controller.js:67:13)

@dnlup
Copy link
Contributor

dnlup commented Apr 6, 2021

In wasm_on_header_field, wasm_on_header_value and wasm_on_body. Is at relative to the global buffer inst.exports.memory.buffer or the instance buffer inst.exports.memory.buffer + this[kPtr]?

I am not sure

@dnlup
Copy link
Contributor

dnlup commented Apr 6, 2021

Strangely it has only happened once so far... there seems to be some kind of interference between requests (parallel test runs?) and the WASM module.
Do we have any global state other than currentParser that might be causing issues?
Do we need to load a separate instance of the WASM module for each client instance?

I'll check about the global state, before we had the Map to keep track of instances, but I doubt that's the problem. I'll see if loading different instances can bring some benefits.

Expanding on this, I don't think we need different WASM instances. That is the reason why the parser reference is passed to every function call.

ronag added a commit that referenced this issue Apr 6, 2021
* fix: use separate web assembly instance for every Client

Refs: #682
Refs: #659

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup
@ronag
Copy link
Member Author

ronag commented Apr 6, 2021

I hope #687 solved this.

@ronag ronag closed this as completed Apr 6, 2021
crysmags pushed a commit to crysmags/undici that referenced this issue Feb 27, 2024
* fix: use separate web assembly instance for every Client

Refs: nodejs#682
Refs: nodejs#659

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants