Skip to content

v5.28.0 - Cannot read properties of undefined (reading 'from') #10553

@michael-wolfenden

Description

@michael-wolfenden

When using 5.28.0 and vite I'm seeing the following error:

WARNING: swagger-ui-react.js?v=5125c5ab:878 Module "buffer" has been externalized for browser compatibility. Cannot access "buffer.Buffer" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

ERROR: Uncaught TypeError: Cannot read properties of undefined (reading 'from')
    at node_modules/safe-buffer/index.js (swagger-ui-react.js?v=5125c5ab:895:17)
    at __require (chunk-X4QARNC5.js?v=5125c5ab:8:50)
    at node_modules/to-buffer/index.js (swagger-ui-react.js?v=5125c5ab:2312:19)
    at __require (chunk-X4QARNC5.js?v=5125c5ab:8:50)
    at swagger-ui-react.js?v=5125c5ab:24376:17

Downgrading to 5.27.1 resolves the issue.

I have a reproduction here:
https://stackblitz.com/edit/vitejs-vite-xyvik7ds?file=src%2Fmain.tsx

Which is only:

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <SwaggerUI url="https://petstore.swagger.io/v2/swagger.json" />;
  </StrictMode>
);

If you refresh the page and view the console you'll see the error

I believe it may be related to the bump in the sha.js version in ff2f2ce

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions