Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Attempted to assign to readonly property. #8

Open
entrptaher opened this issue Aug 4, 2024 · 0 comments
Open

TypeError: Attempted to assign to readonly property. #8

entrptaher opened this issue Aug 4, 2024 · 0 comments

Comments

@entrptaher
Copy link

entrptaher commented Aug 4, 2024

Currently running same code in nodejs works while it throws error in bun. If we check for the runtime, the problem goes away.

Example working code:

if(!process.versions.bun){
  // allows to run same elysia on bun and nodejs
  // otherwise bun throws readonly error
  // 78 | globalThis.Bun = ElysiaBun;
  // TypeError: Attempted to assign to readonly property.
  await import('@bogeychan/elysia-polyfills/node/index.js');
}

import { Elysia } from 'elysia';
const app = new Elysia().get('/', () => ({ hello: 'Node.js👋' })).listen(8080);
console.log(`Listening on http://localhost:${app.server!.port}`);

It would be awesome if the check was done inside the codebase directly so the polyfill does not trigger in the bun runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant