Skip to content

Failed detection of Node.js-environment in Next.js 14+ for orama/plugin-data-persistence #649

@tom-bywild

Description

@tom-bywild

Describe the bug

The plugin @orama/plugin-data-persistence is currently not compatible with Next.js 14 when used on the server. It looks like the Node.js-environment is not correctly detected, therefore some logic reserved to Deno gets executed, thus leading to a crash.

The specific location is in a switch statement in server.ts.

This error happens during runtime when the module gets loaded or during build time.

A quick workaround is to use package-patch and comment-out the relevant statement. But this doesn't work in a monorepo setup due to limitations of package-patch.

To Reproduce

  1. Setup Next.js application (version 14 or newer)
  2. Install Orama + @orama/plugin-data-persistence
  3. Import restoreFromFile from @orama/plugin-data-persistence/server in a server-side function (or RSC)
  4. See error

Expected behavior

Import & usage of module doesn't crash due to invalid Deno-detection.

Environment Info

OS: MacOS 14.3.1
Node: 21.6.2
Orama: 2.0.8
Plugin: 2.0.7

Affected areas

Initialization

Additional context

https://github.com/askorama/orama/blob/8e5e8ef1b74281b90680c4713f849ab5c5f96d57/packages/plugin-data-persistence/src/server.ts#L71

Metadata

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