pollyjs icon indicating copy to clipboard operation
pollyjs copied to clipboard

vue3 vite with arraybuffer. missing module buffer

Open shiftonetothree opened this issue 6 months ago • 1 comments

vue3 vite with arraybuffer. missing module buffer

Shareable Source

const response = await fetch(
    'https://abc.abc.abc/xxx.lerc'
  );
  console.log(response)

Error Message & Stack Trace

VM23117:1 Uncaught ReferenceError: Buffer is not defined
    at eval (eval at isBufferUtf8Representable (is-buffer-utf8-representable.js:9:31), <anonymous>:1:1)
    at isBufferUtf8Representable (is-buffer-utf8-representable.js:9:31)
    at FetchAdapter.onFetchResponse (index.js:182:29)
    at async FetchAdapter.onPassthrough (index.js:159:22)
    at async FetchAdapter.onRecord (index.js:197:32)
    at async FetchAdapter.handleRequest (index.js:91:13)

Config

Copy the config used to setup the Polly instance:

import { Polly } from '@pollyjs/core';
import FetchAdapter from '@pollyjs/adapter-fetch';
import XHRAdapter from '@pollyjs/adapter-xhr';
import LocalStoragePersister from '@pollyjs/persister-local-storage';

Polly.register(FetchAdapter);
Polly.register(XHRAdapter);
Polly.register(LocalStoragePersister);

const polly = new Polly('<Recording Name>', {
  adapters: ['fetch', 'xhr'],
  persister: 'local-storage'
});

const { server } = polly;

server
.host('https://abc.abc.abc', ()=>{
  server.any().intercept((req, res) => {
    debugger;
    console.log(req,res)
  });
})

Dependencies

Copy the @pollyjs dependencies from package.json:

{
    "@pollyjs/adapter-fetch": "^6.0.6",
    "@pollyjs/adapter-xhr": "^6.0.6",
    "@pollyjs/core": "^6.0.6",
    "@pollyjs/persister-local-storage": "^6.0.6",
}

Environment

Node.js v20.7.0 darwin 22.6.0 npm 10.1.0 yarn 1.22.21

shiftonetothree avatar Dec 19 '23 13:12 shiftonetothree

yarn add buffer -Dcan solve this problem

shiftonetothree avatar Dec 19 '23 13:12 shiftonetothree