Description
Support plan
- is this issue currently blocking your project? (yes/no): yes
- is this issue affecting a production system? (yes/no):
Context
- node version: 14.5.0
- module version: 25.0.1
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): Hapi
- any other relevant information: Issue happens in azure pipelines
How can we help?
we are using hapi/lab version 24.0.0 and when we are trying to run the unit test coverage in windows laptop it was throwing following error and not generating html to see the coverage report. hence we updated version to 25.0.1 which worked fine in windows and mac, we were able to see the coverage reports html file. But it started failing in azure pipelines like shown in below snippet. Hence we are blocked and unable to progress on unit test cases. Any help would be highly appreciated.
Windows error:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of null at C:\project\node_modules@hapi\lab\lib\reporters\html.js:143:76 at Array.map () at module.exports.internals.Reporter.internals.Reporter.end (C:\project\node_modules@hapi\lab\lib\reporters\html.js:132:61) at module.exports.internals.Reporter.reporter.finalize (C:\project\node_modules@hapi\lab\lib\reporters\index.js:93:28) at module.exports.internals.Reporter.internals.Reporter.finalize (C:\project\node_modules@hapi\lab\lib\reporters\multiple.js:78:65) at processTicksAndRejections (internal/process/task_queues.js:93:5) at main (C:\project\node_modules@hapi\lab\bin\lab:56:20) (node:5732) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 95)
We also added "@hapi/eslint-plugin" as well.
UnhandledPromiseRejectionWarning: /home/vsts/work/1/s/runner/node_modules/@hapi/lab/lib/cli.js:163
if (pkg.lab?._root) {
^
SyntaxError: Unexpected token '.'
Kindly please let me know if is there any resolution for this? thanks
Activity
cjihrig commentedon May 16, 2023
It looks like you're using syntax that isn't supported by your Node.js version. Node 14 is end-of-life. You're either going to need to update Node to a newer version, or use an older version of lab.
sathyalog commentedon May 17, 2023
@cjihrig - But older versions like 24.0.0 is throwing errors in windows like the following. What should i do now? Kindly advise
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of null at C:\project\node_modules@hapi\lab\lib\reporters\html.js:143:76 at Array.map () at module.exports.internals.Reporter.internals.Reporter.end (C:\project\node_modules@hapi\lab\lib\reporters\html.js:132:61) at module.exports.internals.Reporter.reporter.finalize (C:\project\node_modules@hapi\lab\lib\reporters\index.js:93:28) at module.exports.internals.Reporter.internals.Reporter.finalize (C:\project\node_modules@hapi\lab\lib\reporters\multiple.js:78:65) at processTicksAndRejections (internal/process/task_queues.js:93:5) at main (C:\project\node_modules@hapi\lab\bin\lab:56:20) (node:5732) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode).
cjihrig commentedon May 17, 2023
Oh, you reported two bugs in the same issue 😅. Sorry about that. Reopening. Do you have something that reproduces the issue that you can share with us?
sathyalog commentedon May 17, 2023
@cjihrig Thanks for re-opening :). Sure, let me explain clearly.
My team is working in windows OS having node version v14.5.0 and npm version 6.14.5. We are using "@hapi/lab": "24.0.0" and when we are trying to generate unit test coverage report, we are receiving following errors and report is not generated at all(HTML report where we see coverage file i mean).
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of null at C:\project\node_modules@hapi\lab\lib\reporters\html.js:143:76 at Array.map () at module.exports.internals.Reporter.internals.Reporter.end (C:\project\node_modules@hapi\lab\lib\reporters\html.js:132:61) at module.exports.internals.Reporter.reporter.finalize (C:\project\node_modules@hapi\lab\lib\reporters\index.js:93:28) at module.exports.internals.Reporter.internals.Reporter.finalize (C:\project\node_modules@hapi\lab\lib\reporters\multiple.js:78:65) at processTicksAndRejections (internal/process/task_queues.js:93:5) at main (C:\project\node_modules@hapi\lab\bin\lab:56:20) (node:5732) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode).
When we investigated further and we noticed while debugging in node_modules that cov.files as null with the following error
This issue is only reproducible in Windows OS alone but in Mac OS it works fine and coverage report generates for the same version 24.0.0.
My team is blocked at the moment on this and any help would be really appreciated.
Thanks
kanongil commentedon May 17, 2023
Your versions of both Lab and Node are not only old, but also not even updated to the latest release of the line (v24.7.1 for Lab, and v14.21.3 for node).
We don't have the bandwidth to support such old releases, so please try to update to the never versions and verify that it is still an issue. I expect that you will find that it solves it.
sathyalog commentedon May 17, 2023
Hi @kanongil for some other reasons we are holding the older versions, but anyways i will try like you suggested by updating both lab and node versions. Will keep you posted here. Thank you so much for your time.
sathyalog commentedon May 18, 2023
Hi @kanongil
We tried with v24.7.1 for Lab, and v14.21.3 for node. But we encounter the following error in windows OS(Windows 10 Enterprise). Any suggestions?
[1] "coverage-predicates.type" must be one of [boolean, range, number, string, help] at Object.exports.process (C:\project\node_modules\@hapi\validate\lib\errors.js:160:16) at Object.internals.entry (C:\project\node_modules\@hapi\validate\lib\validator.js:49:26) at Object.exports.entry (C:\project\node_modules\@hapi\validate\lib\validator.js:23:30) at internals.Base.validate (C:\project\node_modules\@hapi\validate\lib\base.js:307:26) at Object.internals.assert (C:\project\node_modules\@hapi\validate\lib\index.js:128:27) at Object.assert (C:\project\node_modules\@hapi\validate\lib\index.js:86:19) at Object.exports.parse (C:\project\node_modules\@hapi\bossy\lib\index.js:17:14) at Object.internals.options (C:\project\runner\node_modules\@hapi\lab\lib\cli.js:479:24) at Object.exports.run (C:\project\runner\node_modules\@hapi\lab\lib\cli.js:28:32) at main (C:\project\runner\node_modules\@hapi\lab\bin\lab:56:50) at Object.<anonymous> (C:\project\runner\node_modules\@hapi\lab\bin\lab:60:1) at Module._compile (internal/modules/cjs/loader.js:1114:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10) at Module.load (internal/modules/cjs/loader.js:979:32) at Function.Module._load (internal/modules/cjs/loader.js:819:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) at internal/main/run_main_module.js:17:47 (Use
node --trace-warnings ...to show where the warning was created) (node:9140) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:9140) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
sathyalog commentedon May 23, 2023
Hi @kanongil @cjihrig - Any updates here? Thanks
roux1max commentedon Jun 7, 2023
Hi @sathyalog!
I just encountered the same issue. The problem is that Lab depends on
@hapi/bossy
to parse CLI arguments but the v24.7.1 version is shipped with@hapi/bossy
v5.0.1 instead of 5.1.1. The "json" argument type is not valid for bossy v5.0.1.A quick way to work around that would be to install your own version of bossy locally which would override the one used by Lab. Just install the
@hapi/bosst@5.1
package.@kanongil I think it's just a matter of fixing the correct dependency here.
roux1max commentedon Jun 7, 2023
Ok, I just realized (actually @Nargonath) that it was a problem with my old
package-lock.json
when I updated from Lab v23 to 24, the dependency to the wrong@hapi/bossy
version was pinned here.So just remove your
node_modules
andpackage-lock.json
and reinstall your packages.kanongil commentedon Jun 7, 2023
@roux1max Thanks for reporting. From your initial description, cached dependencies seemed a likely culprit.