zeromq / zeromq.js

:zap: Node.js bindings to the ØMQ library
http://zeromq.github.io/zeromq.js/
MIT License
1.46k stars 211 forks source link

Refigure gc tests #612

Closed rotu closed 3 months ago

rotu commented 3 months ago

Instead of using weak-napi, use the built-in WeakRef. Use the native garbage collector with {type: 'major', execution: 'async'}. If gc is not available and GC tests not explicitly skipped, fail test explicitly.

rotu commented 3 months ago

The tests fail with this error:

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'SourceFileObject'
    |     property 'statements' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'NodeObject'
    --- property 'parent' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:159:20)
    at process.target._send (node:internal/child_process:845:17)
    at process.target.send (node:internal/child_process:745:19)
    at /home/runner/work/zeromq.js/zeromq.js/node_modules/.pnpm/workerpool@6.2.1/node_modules/workerpool/src/worker.js:139:22

That's interesting.... I can see that here. It's failing when trying to send an error from the Typescript compiler. Curious why this didn't turn up earlier...

"⨯ Unable to compile TypeScript:\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m7\u001b[0m:\u001b[93m1\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m7\u001b[0m describe(\"context process exit\", function () {\r\n\u001b[7m \u001b[0m \u001b[91m~~~~~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m8\u001b[0m:\u001b[93m3\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m8\u001b[0m   describe(\"with default context\", function () {\r\n\u001b[7m \u001b[0m \u001b[91m  ~~~~~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m9\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m9\u001b[0m     it(\"should occur when sockets are closed\", async function () {\r\n\u001b[7m \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m10\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m10\u001b[0m       this.slow(200)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m21\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m21\u001b[0m     it(\"should occur when sockets are not closed\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m22\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m22\u001b[0m       this.slow(200)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m31\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m31\u001b[0m     it(\"should not occur when sockets are open and polling\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m32\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m32\u001b[0m       this.slow(1000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m45\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m45\u001b[0m     it(\"should produce warning when messages are queued with blocky\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m46\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m46\u001b[0m       this.slow(2000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m69\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m69\u001b[0m     it(\"should produce warning when messages are queued without blocky\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m70\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m70\u001b[0m       this.slow(2000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m86\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m86\u001b[0m     it(\"should not produce warning when messages are queued for a short time\", async function () {\r\n\u001b[7m  \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m87\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m87\u001b[0m       this.slow(1000)\r\n\u001b[7m  \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m101\u001b[0m:\u001b[93m3\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m101\u001b[0m   describe(\"with custom context\", function () {\r\n\u001b[7m   \u001b[0m \u001b[91m  ~~~~~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m102\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m102\u001b[0m     it(\"should occur when sockets are closed\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m103\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m103\u001b[0m       this.slow(200)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m115\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m115\u001b[0m     it(\"should occur when sockets are closed and context is gced\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m116\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m116\u001b[0m       this.slow(200)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m133\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m133\u001b[0m     it(\"should occur when sockets are not closed\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m134\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m134\u001b[0m       this.slow(200)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m144\u001b[0m:\u001b[93m5\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2593: \u001b[0mCannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n\r\n\u001b[7m144\u001b[0m     it(\"should not occur when sockets are open and polling\", async function () {\r\n\u001b[7m   \u001b[0m \u001b[91m    ~~\u001b[0m\r\n\u001b[96mtest/unit/context-process-exit-test.ts\u001b[0m:\u001b[93m145\u001b[0m:\u001b[93m7\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2683: \u001b[0m'this' implicitly has type 'any' because it does not have a type annotation.\r\n\r\n\u001b[7m145\u001b[0m       this.slow(1000)\r\n\u001b[7m   \u001b[0m \u001b[91m      ~~~~\u001b[0m\r\n"
aminya commented 3 months ago

Yes, please revert any changes other than the weak-napi changes. Let's get the tests running again.

aminya commented 3 months ago

I moved these changes to #631