typeorm-transactional icon indicating copy to clipboard operation
typeorm-transactional copied to clipboard

TypeError: Cannot redefine property: manager

Open Leonelmarianog opened this issue 2 years ago • 3 comments

Hello,

Using this library with the following NestJS configuration (Webpack's Hot Module Replacement) makes the following error appear when reloading the app.

image

This doesn't break the app but is quite annoying in development.

I tried to fix it by following this question.

image

But it makes it worse.

error-typeorm-transactional-2

What can I do?.

Thanks!.

Leonelmarianog avatar Jan 08 '23 21:01 Leonelmarianog

Created a minimal reproduction repository for this: https://github.com/Leonelmarianog/typeorm-transactional-test

Leonelmarianog avatar Jan 09 '23 17:01 Leonelmarianog

I have the same error, though it only occurs when using the latest version (0.4.1). If I downgrade to 0.3.0 everything works flawlessly.

no-creative-name avatar Feb 27 '23 06:02 no-creative-name

For me it works when I wrap the call to initializeTransactionalContext into a conditional if statement, that checks if there is already a context initialized:

const transactionalContext = getTransactionalContext();
  if (!transactionalContext) {
    initializeTransactionalContext();
  }

getTransactionalContext is imported from typeorm-transactional/dist/common

no-creative-name avatar Jun 05 '23 07:06 no-creative-name