beacon-sdk icon indicating copy to clipboard operation
beacon-sdk copied to clipboard

Package not working with next.js turbo mode `Cannot access 'BeaconError' before initialization`

Open pradel opened this issue 8 months ago • 0 comments

Describe the bug (current behavior)

Following up https://github.com/airgap-it/beacon-sdk/issues/783 update, I tried to upgrade the package in my project but (same as with the older version) I am getting issues with next.js SSR and turbo mode for dev. When you enable turbo mode the following error is thrown Cannot access 'BeaconError' before initialization.

The issue is coming from these imports (affecting all the errors) https://github.com/airgap-it/beacon-sdk/blob/master/packages/beacon-core/src/errors/AbortedBeaconError.ts#L1. Where the BeaconError is imported from the root but should be imported from the BeaconError file directly. This will solve the turbo issues for the errors, don't know if other parts of this package are affected. Webpack and turbo bundle in different ways and it the turbo way is failing right now.

To Reproduce Steps to reproduce the behavior:

  1. Take next.js template with beacon
  2. Enable --turbo flag for next dev
  3. See error Cannot access 'BeaconError' before initialization

Expected (correct) behavior

The server should render fine like without Turbo.

pradel avatar Apr 09 '25 13:04 pradel