pinojs / pino-abstract-transport

Write Pino transports easily
MIT License
34 stars 13 forks source link

Tests are not passing on Node 20 #93

Closed donwellus closed 6 months ago

donwellus commented 6 months ago

Hi there o/

I was developing an integration between Payload CMS, Pino and Grafana Loki, and while I was debugging and testing some things, I cloned the pino-abstract-transport and verify that running the tests for pino-abstract-transport was not working on Node 20.

$ npm run test

> pino-abstract-transport@1.1.0 test
> standard | snazzy && tap test/*.test.js  && tsd

 FAIL ​ test/base.test.js
 ✖ should be equivalent

      same(expected, line)
      same(error.message, 'Unexpected end of JSON input')
------^
    })
  })

  --- expected                                  
  +++ actual                                    
  @@ -1,1 +1,1 @@                               
  -"Unexpected end of JSON input"               
  +"Unterminated string in JSON at position 12" 

  test: test/base.test.js broken json
  at:
    line: 83
    column: 7
    file: test/base.test.js
    type: Transform
  stack: |
    Transform.<anonymous> (test/base.test.js:83:7)
    Transform.split.autoDestroy [as mapper] (index.js:17:12)
    Transform.transform [as _transform] (node_modules/split2/index.js:44:23)
    Test.<anonymous> (test/base.test.js:87:10)
    Object.<anonymous> (test/base.test.js:77:1)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

 FAIL ​ test/base.test.js 1 failed of 73 63.678ms
 ✖ should be equivalent

  🌈 SUMMARY RESULTS 🌈  

 FAIL ​ test/base.test.js 1 failed of 73 63.678ms
 ✖ should be equivalent

Suites:   ​1 failed​, ​1 of 1 completed​
Asserts:  ​​​1 failed​, ​72 passed​, ​of 73​
Time:​   ​259.701ms​
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |      100 |     100 |     100 |                   
 index.js |     100 |      100 |     100 |     100 |                   
----------|---------|----------|---------|---------|-------------------

Looking for the error Unterminated string in JSON at position on the github I came to the v8 repo.

There I found both errors Unterminated string in JSON at position and Unexpected end of JSON input.

So, I realized that it could be because an update on the v8 code, so I changed my Node to 18 and everything works well.

I didn't delve into why json-parser changed in v8, I'm sorry for that.

I'm going to open a PR, with this too small change, and feel free to disagree and close without hard feelings =)