fern icon indicating copy to clipboard operation
fern copied to clipboard

[Bug] Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme) - runtime: `browser` nextjs react react-query

Open tresorama opened this issue 1 year ago • 3 comments

Describe the Bug

Trying to use the generated SDK for Typescript inside a React app with Next.js in browser runtime (use client) trigger this error

Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).

All working in a Server Component that use Node runtime. Tested only in local dev.

Information to Reproduce

CLI Version

{
    "organization": "xxxxx",
    "version": "0.43.5"
}

Generator Version

default-group: local
groups:
  local:
    generators:
      - name: fernapi/fern-typescript-node-sdk
        version: 0.39.3
        output:
          location: local-file-system
          path: ../sdks/typescript
api:
  path: openapi/openapi.yml

API Definition

Irrelevant.

Actual SDK

Don't know what to write here

Expected SDK

Don't know what to write here

tresorama avatar Sep 27 '24 01:09 tresorama

I presume this is expected behavior, meaning that the SDK is not supposed to work on browser runtime. It's my first time using fern.

In case is not supported, is planned for the future ?

tresorama avatar Sep 27 '24 01:09 tresorama

@tresorama can you:

  1. disable these in your package.json
  2. turn on the config flag for outputEsm and see if that works

dsinghvi avatar Sep 27 '24 11:09 dsinghvi

disable these in your package.json

In package.json of sdk consumer app (next.js) or in the project that generate the sdk ?

  1. turn on the config flag for outputEsm and see if that works

Where do I add this ?


My current setup

.
├── backend (fastify + fastify-swagger)
│   ├── package.json
│   ├── src
│   │   ├── plugins
│   │   │   └── fastify-swagger
│   │   └── server.ts
│   └── tsconfig.json
├── frontend (next js)
│   ├── next.config.mjs
│   ├── package.json
│   ├── src
│   │   ├── app
│   │   │   ├── dashboard
│   │   │   ├── globals.css
│   │   │   ├── layout.tsx
│   │   ├── auth
│   │   │   └── auth.login.tsx
│   │   └── lib
│   │       ├── fetcher
│   │       ├── react-query.tsx
│   │       └── utils.ts
│   ├── tailwind.config.ts
│   └── tsconfig.json
└── openapi (fern cli )
    ├── fern
    │   ├── fern.config.json
    │   ├── generators.yml
    │   └── openapi
    │       └── openapi.yml
    ├── package.json
    └── sdks
        └── typescript
            ├── Client.d.ts
            ├── Client.js
            ├── api
            ├── core
            ├── environments.d.ts
            ├── environments.js
            ├── errors
            ├── index.d.ts
            ├── index.js
            └── serialization

tresorama avatar Sep 27 '24 14:09 tresorama

@tresorama sorry for the delayed reply here!

You can add the config flag for outputEsm via your generators.yml: https://github.com/fern-api/fern/blob/main/generators/typescript/README.md#-outputesm

dannysheridan avatar Dec 24 '24 23:12 dannysheridan