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

Wrong Object prototype in repl context #12916

Closed
4 of 15 tasks
othierry opened this issue Dec 12, 2023 · 3 comments
Closed
4 of 15 tasks

Wrong Object prototype in repl context #12916

othierry opened this issue Dec 12, 2023 · 3 comments
Labels
needs triage This issue has not been looked into

Comments

@othierry
Copy link
Contributor

othierry commented Dec 12, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Hello Nestjs team! 👋

Object prototype in nestjs repl context seems to diverge from the Object prototype from main context. See the code sandbox below to see an example.

This causes runtime issues in repl especially for libraries (ex: typeorm 0.2.45) which checks for instanceof Object at runtime.

// typeorm ex.
$(UserDAO).update({ id: 42 }, { firstName: 'oli' }) // will throw in repl and work in node

As described here the issue was confirmed in node.js repl module.

When using useGlobal: true in the repl start() options, it works as expected (solution given here).

Minimum reproduction code

https://codesandbox.io/p/devbox/jolly-kapitsa-ynrtcq

Steps to reproduce

From code sandbox

yarn start
> x = {}
{}
> x instanceof Object
true
> $(AppService).isInstanceOfObject(x)
false
> $(AppService).isSpreadCopyInstanceOfObject(x)
true

Expected behavior

As described here the issue was confirmed in node'js repl module.

When using useGlobal: true in the repl start() options it works as expected (solution given here).

Potential solution: Allowing node's repl start options has a second parameter of nestjs's repl function would allow users to specify specific options such as useGlobal if needed.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

10.0.0

Packages versions

    "@nestjs/common": "^10.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/cli": "^10.0.1",
    "@nestjs/schematics": "^10.0.1",
    "@nestjs/testing": "^10.0.0",

Node.js version

20.9.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@othierry othierry added the needs triage This issue has not been looked into label Dec 12, 2023
@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@othierry
Copy link
Contributor Author

Would you like to create a PR for this issue?

Sure 👍

othierry added a commit to othierry/nest that referenced this issue Dec 15, 2023
othierry added a commit to othierry/nest that referenced this issue Dec 15, 2023
Enables passing node repl options parameter to nestjs/core/repl

fixes nestjs#12916
@kamilmysliwiec
Copy link
Member

Let's track this here #12924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants