Skip to content

stream-use-after-error: failing test case #2829

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

Closed
wants to merge 5 commits into from

Conversation

alxndrsn
Copy link
Contributor

@alxndrsn alxndrsn commented Oct 3, 2022

Failing test case for #1674

On my machine, running postgres using docker run --rm --name test_node_pg -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=ci_db_test -e POSTGRES_USER=postgres postgres:11, this sometimes fails with different errors:

$ PGTESTNOSSL=true PGUSER=postgres PGPASSWORD=postgres PGDATABASE=ci_db_test yarn test
yarn run v1.22.15
$ mocha -r ts-node/register test/**/*.ts


  use after error
    1) should work if used after error


  0 passing (547ms)
  1 failing

  1) use after error
       should work if used after error:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ []
- [
-   {
-     bool: true
-   }
- ]
      + expected - actual

      -[]
      +[
      +  {
      +    "bool": true
      +  }
      +]
      
      at ~/node-postgres/packages/pg-query-stream/test/close.ts:112:14
      at Generator.next (<anonymous>)
      at fulfilled (test/close.ts:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)



^[[A^C[11:23] ~/node-postgres/packages/pg-query-stream (stream-after-error*)
$ PGTESTNOSSL=true PGUSER=postgres PGPASSWORD=postgres PGDATABASE=ci_db_test yarn test
yarn run v1.22.15
$ mocha -r ts-node/register test/**/*.ts


  use after error
    1) should work if used after error
    2) should work if used after error


  0 passing (547ms)
  2 failing

  1) use after error
       should work if used after error:
     Uncaught TypeError: Cannot read properties of null (reading 'handleRowDescription')
      at Client._handleRowDescription (~/node-postgres/packages/pg/lib/client.js:340:22)
      at Connection.emit (node:events:513:28)
      at ~/node-postgres/packages/pg/lib/connection.js:114:12
      at Parser.parse (~/node-postgres/packages/pg-protocol/src/parser.ts:104:9)
      at Socket.<anonymous> (~/node-postgres/packages/pg-protocol/src/index.ts:7:48)
      at Socket.emit (node:events:513:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at Socket.Readable.push (node:internal/streams/readable:228:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

  2) use after error
       should work if used after error:
     Error: done() called multiple times in test <use after error should work if used after error> of file ~/node-postgres/packages/pg-query-stream/test/close.ts; in addition, done() received error: AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ []
- [
-   {
-     bool: true
-   }
- ]
      at processTicksAndRejections (node:internal/process/task_queues:96:5)



error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@alxndrsn
Copy link
Contributor Author

alxndrsn commented Oct 3, 2022

I've added a hack to make the tests pass. To enable the hack, add the environment variable WAIT_AFTER_CLOSE=1, e.g.:

WAIT_AFTER_CLOSE=1 PGTESTNOSSL=true PGUSER=postgres PGPASSWORD=postgres PGDATABASE=ci_db_test yarn test

@alxndrsn
Copy link
Contributor Author

alxndrsn commented Oct 3, 2022

I've added an alternative hack, which can be enabled like so:

WAIT_AFTER_CLOSE=2 PGTESTNOSSL=true PGUSER=postgres PGPASSWORD=postgres PGDATABASE=ci_db_test yarn test

@alxndrsn
Copy link
Contributor Author

alxndrsn commented Jul 5, 2023

Included in #2836

@alxndrsn alxndrsn closed this Jul 5, 2023
Sign up for free to 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.

1 participant