Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM meta filename check fails #5

Open
ilteoood opened this issue Nov 5, 2024 · 0 comments
Open

ESM meta filename check fails #5

ilteoood opened this issue Nov 5, 2024 · 0 comments

Comments

@ilteoood
Copy link

ilteoood commented Nov 5, 2024

Node version: 22.10.0
OS: OS X 14.7

Reproducible example:
Put the following piece of code in a file named index.mjs, and run it using the command node ./index.mjs

if (process.argv[1] === import.meta.filename) {
    const results = cronometro({
        async test1() {
            // Do something
        },
        async test2() {
            // Do something else
        }
    }, {
        onTestError: console.error
    })
}

It will print the following output:

test1 TypeError [Error]: Cannot read properties of undefined (reading '0')
    at runWorker (file:///Users/ilteoood/Documents/git/personal/napi-rs-benchmark/node_modules/cronometro/dist/worker.js:134:41)
    at file:///Users/ilteoood/Documents/git/personal/napi-rs-benchmark/node_modules/cronometro/dist/runner.js:18:5 Worker {
  _events: [Object: null prototype] {
    newListener: [Function (anonymous)],
    removeListener: [Function (anonymous)],
    error: [Function (anonymous)],
    message: [Function (anonymous)]
  },
  _eventsCount: 4,
  _maxListeners: undefined,
  performance: { eventLoopUtilization: [Function: bound eventLoopUtilization] },
  [Symbol(shapeMode)]: false,
  [Symbol(kCapture)]: false,
  [Symbol(kHandle)]: Worker {
    messagePort: MessagePort [EventTarget] {
      active: true,
      refed: false,
      [Symbol(kEvents)]: [SafeMap [Map]],
      [Symbol(events.maxEventTargetListeners)]: 10,
      [Symbol(events.maxEventTargetListenersWarned)]: false,
      [Symbol(kHandlers)]: SafeMap(0) [Map] {},
      [Symbol(kNewListener)]: [Function (anonymous)],
      [Symbol(kRemoveListener)]: [Function (anonymous)],
      [Symbol(nodejs.internal.kCurrentlyReceivingPorts)]: undefined,
      [Symbol(kWaitingStreams)]: 0
    },
    threadId: 1,
    onexit: [Function (anonymous)]
  },
  [Symbol(kPort)]: MessagePort [EventTarget] {
    active: true,
    refed: false,
    [Symbol(kEvents)]: SafeMap(3) [Map] {
      'newListener' => [Object],
      'removeListener' => [Object],
      'message' => [Object]
    },
    [Symbol(events.maxEventTargetListeners)]: 10,
    [Symbol(events.maxEventTargetListenersWarned)]: false,
    [Symbol(kHandlers)]: SafeMap(0) [Map] {},
    [Symbol(kNewListener)]: [Function (anonymous)],
    [Symbol(kRemoveListener)]: [Function (anonymous)],
    [Symbol(nodejs.internal.kCurrentlyReceivingPorts)]: undefined,
    [Symbol(kWaitingStreams)]: 0
  },
  [Symbol(kParentSideStdio)]: {
    stdin: null,
    stdout: ReadableWorkerStdio {
      _events: [Object],
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _eventsCount: 2,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kPort)]: [MessagePort [EventTarget]],
      [Symbol(kName)]: 'stdout',
      [Symbol(kIncrementsPortRef)]: false,
      [Symbol(kStartedReading)]: false
    },
    stderr: ReadableWorkerStdio {
      _events: [Object],
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _eventsCount: 2,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kPort)]: [MessagePort [EventTarget]],
      [Symbol(kName)]: 'stderr',
      [Symbol(kIncrementsPortRef)]: false,
      [Symbol(kStartedReading)]: false
    }
  },
  [Symbol(kPublicPort)]: MessagePort [EventTarget] {
    active: true,
    refed: true,
    [Symbol(kEvents)]: SafeMap(4) [Map] {
      'newListener' => [Object],
      'removeListener' => [Object],
      'message' => [Object],
      'messageerror' => [Object]
    },
    [Symbol(events.maxEventTargetListeners)]: 10,
    [Symbol(events.maxEventTargetListenersWarned)]: false,
    [Symbol(kHandlers)]: SafeMap(0) [Map] {},
    [Symbol(kNewListener)]: [Function (anonymous)],
    [Symbol(kRemoveListener)]: [Function (anonymous)],
    [Symbol(nodejs.internal.kCurrentlyReceivingPorts)]: undefined
  },
  [Symbol(kNewListener)]: [Function (anonymous)],
  [Symbol(kRemoveListener)]: [Function (anonymous)],
  [Symbol(kLoopStartTime)]: -1,
  [Symbol(kIsOnline)]: true
}
test2 TypeError [Error]: Cannot read properties of undefined (reading '1')
    at runWorker (file:///Users/ilteoood/Documents/git/personal/napi-rs-benchmark/node_modules/cronometro/dist/worker.js:134:41)
    at file:///Users/ilteoood/Documents/git/personal/napi-rs-benchmark/node_modules/cronometro/dist/runner.js:18:5 Worker {
  _events: [Object: null prototype] {
    newListener: [Function (anonymous)],
    removeListener: [Function (anonymous)],
    error: [Function (anonymous)],
    message: [Function (anonymous)]
  },
  _eventsCount: 4,
  _maxListeners: undefined,
  performance: { eventLoopUtilization: [Function: bound eventLoopUtilization] },
  [Symbol(shapeMode)]: false,
  [Symbol(kCapture)]: false,
  [Symbol(kHandle)]: Worker {
    messagePort: MessagePort [EventTarget] {
      active: true,
      refed: false,
      [Symbol(kEvents)]: [SafeMap [Map]],
      [Symbol(events.maxEventTargetListeners)]: 10,
      [Symbol(events.maxEventTargetListenersWarned)]: false,
      [Symbol(kHandlers)]: SafeMap(0) [Map] {},
      [Symbol(kNewListener)]: [Function (anonymous)],
      [Symbol(kRemoveListener)]: [Function (anonymous)],
      [Symbol(nodejs.internal.kCurrentlyReceivingPorts)]: undefined,
      [Symbol(kWaitingStreams)]: 0
    },
    threadId: 2,
    onexit: [Function (anonymous)]
  },
  [Symbol(kPort)]: MessagePort [EventTarget] {
    active: true,
    refed: false,
    [Symbol(kEvents)]: SafeMap(3) [Map] {
      'newListener' => [Object],
      'removeListener' => [Object],
      'message' => [Object]
    },
    [Symbol(events.maxEventTargetListeners)]: 10,
    [Symbol(events.maxEventTargetListenersWarned)]: false,
    [Symbol(kHandlers)]: SafeMap(0) [Map] {},
    [Symbol(kNewListener)]: [Function (anonymous)],
    [Symbol(kRemoveListener)]: [Function (anonymous)],
    [Symbol(nodejs.internal.kCurrentlyReceivingPorts)]: undefined,
    [Symbol(kWaitingStreams)]: 0
  },
  [Symbol(kParentSideStdio)]: {
    stdin: null,
    stdout: ReadableWorkerStdio {
      _events: [Object],
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _eventsCount: 2,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kPort)]: [MessagePort [EventTarget]],
      [Symbol(kName)]: 'stdout',
      [Symbol(kIncrementsPortRef)]: false,
      [Symbol(kStartedReading)]: false
    },
    stderr: ReadableWorkerStdio {
      _events: [Object],
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _eventsCount: 2,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kPort)]: [MessagePort [EventTarget]],
      [Symbol(kName)]: 'stderr',
      [Symbol(kIncrementsPortRef)]: false,
      [Symbol(kStartedReading)]: false
    }
  },
  [Symbol(kPublicPort)]: MessagePort [EventTarget] {
    active: true,
    refed: true,
    [Symbol(kEvents)]: SafeMap(4) [Map] {
      'newListener' => [Object],
      'removeListener' => [Object],
      'message' => [Object],
      'messageerror' => [Object]
    },
    [Symbol(events.maxEventTargetListeners)]: 10,
    [Symbol(events.maxEventTargetListenersWarned)]: false,
    [Symbol(kHandlers)]: SafeMap(0) [Map] {},
    [Symbol(kNewListener)]: [Function (anonymous)],
    [Symbol(kRemoveListener)]: [Function (anonymous)],
    [Symbol(nodejs.internal.kCurrentlyReceivingPorts)]: undefined
  },
  [Symbol(kNewListener)]: [Function (anonymous)],
  [Symbol(kRemoveListener)]: [Function (anonymous)],
  [Symbol(kLoopStartTime)]: -1,
  [Symbol(kIsOnline)]: true
}
╔══════════════╤═════════╤═════════╤═══════════╗
║ Slower tests │ Samples │  Result │ Tolerance ║
╟──────────────┼─────────┼─────────┼───────────╢
║ test2        │       0 │ Errored │       N/A ║
╟──────────────┼─────────┼─────────┼───────────╢
║ Fastest test │ Samples │  Result │ Tolerance ║
╟──────────────┼─────────┼─────────┼───────────╢
║ test1        │       0 │ Errored │       N/A ║
╚══════════════╧═════════╧═════════╧═══════════╝
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant