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

Error when using transaction timeout #471

Open
nicoskk opened this issue Jan 12, 2021 · 6 comments
Open

Error when using transaction timeout #471

nicoskk opened this issue Jan 12, 2021 · 6 comments
Labels

Comments

@nicoskk
Copy link

nicoskk commented Jan 12, 2021

Steps to reproduce

loopback-connector-postgresql version is 5.3.0
node version is v14.1.0

await app.datasources.db.transaction(async myTxModels => {
    await customFunction(element, {
        db1: db1TxModels, 
        db2: db2Models
    }).catch(err => { throw err });

}, { timeout: 240000 });

Current Behavior

aftersome time, app crashes with the following error

tx.notifyObserversOf('timeout', context, function(err) {
           ^

TypeError: tx.notifyObserversOf is not a function
    at Timeout._onTimeout (\node_modules\loopback-connector\lib\transaction.js:124:12)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
@nicoskk nicoskk added the bug label Jan 12, 2021
@stale
Copy link

stale bot commented Jul 12, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 12, 2021
@stale
Copy link

stale bot commented Jul 26, 2021

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Jul 26, 2021
@cluis13915
Copy link

I'm experiencing this issue ! 😕 I'm in the process of upgrading a node project running with Node 10, bringing it to the latest version of Node (v14.17.3).

I have some behaviour tests (endpoint tests) to make sure that I didn't break anything. When I execute my tests, at random points (after at least 5 seconds, so many requests) my backend crashes with the following error:

TypeError: tx.notifyObserversOf is not a function
    at Timeout._onTimeout (/home/cluis/Projects/Exeboard/dev/exeboard-web-2/backend/node_modules/loopback-connector/lib/transaction.js:124:12)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
[nodemon] app crashed - waiting for file changes before starting...

I have no idea what is happening because the error ocurrs at random places. Help, please !!!

    "loopback": "^3.28.0",
    "loopback-boot": "^3.3.1",
    "loopback-component-explorer": "^6.5.1",
    "loopback-connector-postgresql": "5.4.0",
    "loopback-console": "^1.1.0",

@achrinza achrinza removed the stale label Sep 23, 2021
@achrinza achrinza reopened this Sep 23, 2021
@prachitin
Copy link

@cluis13915 @nicoskk I am facing the same issue, have you came across any solution for this?

@cluis13915
Copy link

@prachitin I just avoided setting the timeout option in Model.beginTransaction({ ...options }, callback) 😕

@lchaglla
Copy link

Since version 5.1.0 which updates its dependencies (loopback-connector: ^5.0.0) It will give this error with loopback 3.
The latest version of loopback 3 (3.28.0) depends on loopback-datasource-juggler which depends on loopback-connector: "^4.4.0"

The transaction is created with loopback-connector@5 for loopback-connector-postgresql, but loopback will use loopback-connector@4 which is modified by this line https://github.com/loopbackio/loopback-datasource-juggler/blob/3.x/lib/transaction.js#L117

The solution I found was to install loopback-connector as a direct dependency
npm install loopback-connector@5
This makes all packages use the same version of the package with the ObserverMixin applied to it

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

No branches or pull requests

5 participants