1. Apr 29, 2021
  2. Apr 28, 2021
  3. Apr 27, 2021
  4. Apr 26, 2021
    • James M Snell's avatar
      lib: add support for JSTransferable as a mixin · bbe24e21
      James M Snell authored
      
      
      Adds a new `makeTransferable()` utility that can construct a
      `JSTransferable` object that does not directly extend the
      `JSTransferable` JavaScript class.
      
      Because JavaScript does not support multiple inheritance, it is
      not possible (without help) to implement a class that extends
      both `JSTransferable` and, for instance, `EventTarget` without
      incurring a significant additional complexity and performance
      cost by making all `EventTarget` instances extend `JSTransferable`...
      
      That is, we *don't* want:
      
      ```js
      class EventTarget extends JSTransferable { ... }
      ```
      
      The `makeTransferable()` allows us to create objects that are
      backed internally by `JSTransferable` without having to actually
      extend it by leveraging the magic of `Reflect.construct()`.
      
      ```js
      const {
        JSTransferable,
        kClone,
        kDeserialize,
        kConstructor,
        makeTransferable,
      } = require('internal/worker/js_transferable');
      
      class E {
        constructor(b) {
          this.b = b;
        }
      }
      
      class F extends E {
        [kClone]() { /** ... **/ }
        [kDeserialize]() { /** ... **/ }
      
        static [kConstructor]() { return makeTransferable(F); }
      }
      
      const f = makeTransferable(F, 1);
      
      f instanceof F;  // true
      f instanceof E;  // true
      f instanceof JSTransferable;  // false
      
      const mc = new MessageChannel();
      mc.port1.onmessage = ({ data }) => {
        data instanceof F;  // true
        data instanceof E;  // true
        data instanceof JSTransferable;  // false
      };
      mc.port2.postMessage(f);  // works!
      ```
      
      The additional `internal/test/transfer.js` file is required for the
      test because successfully deserializing transferable classes requires
      that they be located in `lib/internal` for now.
      
      Signed-off-by: default avatarJames M Snell <jasnell@gmail.com>
      
      PR-URL: https://github.com/nodejs/node/pull/38383
      
      
      Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
      Reviewed-By: default avatarKhaidi Chu <i@2333.moe>
      bbe24e21
    • Richard Lau's avatar
      test: fix test to allow quictls fork of OpenSSL 3 · dee37412
      Richard Lau authored
      The quictls fork of OpenSSL identifies itself with a `+quic` suffix
      in its version string. This was previously rejected by the version
      string check as the `+` was not an allowed character.
      
      PR-URL: https://github.com/nodejs/node/pull/38372
      Refs: https://github.com/nodejs/node/commit/7ac626505d2f6f2e603bd7c9ddb356c893bbbe55
      
      
      Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
      Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
      Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
      dee37412