winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.59k stars 180 forks source link

fix: cli cleanup is skipped when multiple signals are sent #6374

Closed MarkMcCulloh closed 2 weeks ago

MarkMcCulloh commented 2 weeks ago

Finally was able to reproduce the issue locally. Depending on how it is executed, it is possible the CLI will receive multiple SIGINT signals when a user hits CTRL^C (even when pressed once).

Using process.once handled the first signal and then started our cleanup process. However, the second signal came along and no longer had a handler because the first process.once was used up. So then node returns to its default behavior, which is to immediately process.exit(). process.exit() Stops the process kills the process without waiting for the event loop to finish so thus the cleanup process is interrupted.

Other changes:

Reproducing: I noticed this happening with a globally installed version of the CLI, but no with my local dev version. So to test this fix, I manually replaced the compiled .js for this particular util file in the global version. I do not know why this only happens with the global version.

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

github-actions[bot] commented 2 weeks ago

Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistence, don't hesitate to ping the relevant owner over Slack.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon
monadabot commented 2 weeks ago

Benchmarks

Comparison to Baseline ⬜🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ | Benchmark | Before | After | Change | | :-- | --: | --: | --: | | version | 58ms±1.36 | 61ms±1.63 | +3ms (+5.65%)⬜ | | functions_1.test.w -t sim | 401ms±5.12 | 413ms±2.42 | +12ms (+2.94%)🟥 | | functions_1.test.w -t tf-aws | 852ms±9.26 | 873ms±13.64 | +22ms (+2.53%)⬜ | | jsii_big.test.w -t sim | 2888ms±20.1 | 2872ms±13.15 | -16ms (-0.55%)⬜ | | jsii_big.test.w -t tf-aws | 3087ms±19.69 | 3102ms±19.83 | +14ms (+0.47%)⬜ | | functions_10.test.w -t sim | 509ms±11.46 | 513ms±12.88 | +5ms (+0.95%)⬜ | | functions_10.test.w -t tf-aws | 2112ms±10.4 | 2119ms±16.92 | +7ms (+0.34%)⬜ | | jsii_small.test.w -t sim | 378ms±4.74 | 383ms±4.51 | +4ms (+1.13%)⬜ | | jsii_small.test.w -t tf-aws | 627ms±5.31 | 635ms±6.61 | +8ms (+1.35%)⬜ | | empty.test.w -t sim | 379ms±2.58 | 377ms±5.09 | -2ms (-0.45%)⬜ | | empty.test.w -t tf-aws | 617ms±6.6 | 622ms±2.51 | +6ms (+0.9%)⬜ | | hello_world.test.w -t sim | 425ms±19.06 | 416ms±5.23 | -10ms (-2.31%)⬜ | | hello_world.test.w -t tf-aws | 1559ms±12.51 | 1562ms±7.76 | +3ms (+0.2%)⬜ | ⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations _Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI._
Results |name|mean|min|max|moe|sd| |----|----|----|----|----|----| |version|61ms|59ms|67ms|2ms|2ms| |functions_1.test.w -t sim|413ms|407ms|418ms|2ms|3ms| |functions_1.test.w -t tf-aws|873ms|850ms|908ms|14ms|19ms| |jsii_big.test.w -t sim|2872ms|2843ms|2900ms|13ms|18ms| |jsii_big.test.w -t tf-aws|3102ms|3075ms|3153ms|20ms|28ms| |functions_10.test.w -t sim|513ms|482ms|533ms|13ms|18ms| |functions_10.test.w -t tf-aws|2119ms|2080ms|2162ms|17ms|24ms| |jsii_small.test.w -t sim|383ms|371ms|394ms|5ms|6ms| |jsii_small.test.w -t tf-aws|635ms|623ms|651ms|7ms|9ms| |empty.test.w -t sim|377ms|368ms|392ms|5ms|7ms| |empty.test.w -t tf-aws|622ms|619ms|629ms|3ms|4ms| |hello_world.test.w -t sim|416ms|402ms|422ms|5ms|7ms| |hello_world.test.w -t tf-aws|1562ms|1536ms|1573ms|8ms|11ms|
Last Updated (UTC) 2024-04-29 13:26
mergify[bot] commented 2 weeks ago

Thanks for contributing, @MarkMcCulloh! This PR will now be added to the merge queue, or immediately merged if mark/multiple-signals-break is up-to-date with main and the queue is empty.

monadabot commented 2 weeks ago

Congrats! :rocket: This was released in Wing 0.73.10.