stepci: [Bug]: UnhandledPromiseRejection in posthog-node 2.2.1
What happened?
When I run the test using the stepci CLI, the test itself succeeds, but then I get an error UnhandledPromiseRejection.
$ stepci run ./workflow.yml
PASS example
Tests: 0 failed, 1 passed, 1 total
Steps: 0 failed, 1 passed, 1 total
Time: 0.109s, estimated 0s
Workflow passed after 0.109s
Give us your feedback on https://step.ci/feedback
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: 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(). The promise rejected with the reason "CanceledError: canceled".] {
code: 'ERR_UNHANDLED_REJECTION'
}
workflow.yml:
version: "1.1"
name: Validating JSON
config:
http:
baseURL: https://jsonplaceholder.typicode.com
env:
postId: "2"
tests:
example:
steps:
- name: GET request
http:
url: /posts/${{env.postId}}
method: GET
check:
status: 200
jsonpath:
$.id: ${{env.postId}}
$.userId: 1
The same error occurs when using github actions.
logs: https://github.com/koki-develop/stepci-example/actions/runs/3551276044/jobs/5965323631
.github/workflows/main.yml:
name: api test
on:
push:
jobs:
with-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stepci/stepci@main
with:
workflow: workflow.yml
This error does not occur when using @stepci/runner, so there may be some problem with stepci cli.
The workflow below uses @stepci/runner in vitest, but no error occurs.
logs: https://github.com/koki-develop/stepci-example/actions/runs/3551276044/jobs/5965323586
What did you expect to happen?
After the test is completed, it ends without error as it is.
Version
2.5.1
Environment
Node v16.18.1
How can we reproduce this bug?
commands:
$ git clone git@github.com:koki-develop/stepci-example.git
$ cd stepci-example
$ stepci run ./workflow.yml
output:
PASS example
Tests: 0 failed, 1 passed, 1 total
Steps: 0 failed, 1 passed, 1 total
Time: 0.132s, estimated 0s
Workflow passed after 0.132s
Give us your feedback on https://step.ci/feedback
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: 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(). The promise rejected with the reason "CanceledError: canceled".] {
code: 'ERR_UNHANDLED_REJECTION'
}
exit code:
$ echo $?
1
Relevant log output
PASS example
Tests: 0 failed, 1 passed, 1 total
Steps: 0 failed, 1 passed, 1 total
Time: 0.132s, estimated 0s
Workflow passed after 0.132s
Give us your feedback on https://step.ci/feedback
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: 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(). The promise rejected with the reason "CanceledError: canceled".] {
code: 'ERR_UNHANDLED_REJECTION'
}
Would you be interested in working on a bugfix for this issue?
- Yes! Assign me
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (22 by maintainers)
Commits related to this issue
- Pinned posthog version due to #74 — committed to stepci/stepci by mishushakov 2 years ago
- Pinned posthog version due to #74 — committed to stepci/stepci by mishushakov 2 years ago
- Pinned posthog version due to #74 — committed to stepci/stepci by mishushakov 2 years ago
- Pinned posthog version due to #74 — committed to stepci/stepci by mishushakov 2 years ago
Done, thank you so much! Now youβre one of us, officially: https://github.com/stepci/stepci/graphs/contributors
π
Hey @koki-develop, can I ask you for a small thing? Could you update
posthog-nodein our package.json to^2.2.2and open a Pull Request?The reason Iβm asking is because Iβd like to give you a credit for your work on the issue π
Thank you very much
No worries, Iβll fill the report and reference you there. Please update stepci to
2.5.5Thanks for looking into it πThanks to you for finding the bug and filling the issue! Was a pleasure to help π
I just upgraded stepci to version 2.5.5 and the error no longer occurs! πββοΈ Thanks for the quick response! β€οΈ
Resolved! posthog allows a timeout to be set when sending a request, and the default timeout value is 10ms.
https://github.com/PostHog/posthog-js-lite/blob/7b26cde29a2e18ac23681128ae64fcd918c09597/posthog-core/src/index.ts#L71
The request itself was successfully sent, but because it took more than 10 ms, it is considered a failure and this error occurs. I was able to avoid this error by setting a longer timeout when initializing the PostHog instance.
Iβll create a Pull Request! πββοΈ
The error happens after
posthog.shutdown()in lib/analytics.ts is calledGetting the same error on my local environment now
I just tried it with the latest v2.5.4 and found something new. The same error still occurs, but when I set the
STEPCI_DISABLE_ANALYTICSenvironment variable, the error did not occur. Something may be happening where data is being sent to posthog π€