Skip to content

The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object #7082

Closed
@dimaMachina

Description

Describe the bug

I am migrating tests from jest to vitest and ran into an error from this line

deserialize: v => v8.deserialize(Buffer.from(v)),
or this line (these functions are identical, so I am not sure which is right)
deserialize: v => v8.deserialize(Buffer.from(v)),

here is the stack trace

TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object
 ❯ Function.from node:buffer:319:9
 ❯ deserialize ../../node_modules/vitest/dist/chunks/resolveConfig.RxKrDli4.js:6716:67
 ❯ EventEmitter.onMessage ../../node_modules/vitest/dist/chunks/index.68735LiX.js:82:17
 ❯ EventEmitter.emit node:events:519:28
 ❯ Object.postMessage ../../node_modules/vitest/dist/chunks/resolveConfig.RxKrDli4.js:6711:39
 ❯ ChildProcess.<anonymous> ../../node_modules/tinypool/dist/index.js:216:30
 ❯ ChildProcess.emit node:events:519:28
 ❯ emit node:internal/child_process:951:14
 ❯ process.processTicksAndRejections node:internal/process/task_queues:83:21

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-qyahuvyc?file=test%2Fbasic.test.ts

v argument in my case is

{
  v: {
    jsonrpc: '2.0',
    method: 'window/logMessage',
    params: {
      type: 1,
      message: 'Received message which is neither a response nor a notification message:\n' +
        '{\n' +
        '    "type": "Buffer",\n' +
        '    "data": [\n' +
        '        255,\n' +
        '        15,\n' +
        '        111,\n' +
        '        34,\n' +
        '        1,\n' +
        '        116,\n' +
        '        34,\n' +
        '        1,\n' +
        '        115,\n' +
        '        34,\n' +
        '        1,\n' +
        '        105,\n' +
        '        34,\n' +
        '        21,\n' +
        '        71,\n' +
        '        101,\n' +
        '        112,\n' +
        '        110,\n' +
        '        56,\n' +
        '        49,\n' +
        '        99,\n' +
        '        73,\n' +
        '        122,\n' +
        '        98,\n' +
        '        52,\n' +
        '        102,\n' +
        '        55,\n' +
        '        106,\n' +
        '        105,\n' +
        '        77,\n' +
        '        50,\n' +
        '        57,\n' +
        '        48,\n' +
        '        122,\n' +
        '        108,\n' +
        '        34,\n' +
        '        1,\n' +
        '        114,\n' +
        '        95,\n' +
        '        34,\n' +
        '        1,\n' +
        '        101,\n' +
        '        95,\n' +
        '        123,\n' +
        '        4\n' +
        '    ]\n' +
        '}'
    }
  }
}

System Info

System:
    OS: macOS 13.4
    CPU: (12) x64 Apple M2 Max
    Memory: 8.74 GB / 96.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.local/state/fnm_multishells/55235_1734137834788/bin/node
    Yarn: 1.22.22 - ~/.local/state/fnm_multishells/55235_1734137834788/bin/yarn
    npm: 10.8.2 - ~/.local/state/fnm_multishells/55235_1734137834788/bin/npm
    Watchman: 2024.08.05.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 128.0.6613.114
    Safari: 16.5
  npmPackages:
    vitest: ^2.1.8 => 2.1.8

Used Package Manager

yarn

Validations

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions