Closed luke-jia closed 4 years ago
@luke-jia, what's your Node.js version you're using? And could you please run the following command to list the LB modules you're using? Thanks.
npm ls --prod --depth 0 | grep loopback
I have the same issue with node v10.16.3 and
├── loopback@3.26.0
├── loopback-boot@2.28.0
├── loopback-component-explorer@4.3.1
├── loopback-component-migrate@0.3.5
├── loopback-component-storage@3.6.3
├── loopback-connector-postgresql@3.8.0
├── loopback-connector-rest@2.1.0
├── loopback-context@3.4.0
@luke-jia @alejandroBrb , sorry about the late response. Could you please provide steps to reproduce and possibly a sample application as well? @luke-jia, you've mentioned it doesn't work in the latest version of code. Could you also please elaborate on the module name, the version that used to work and the version that no longer works. Thanks!
Here is the relevant code, assuming we are talking about the latest version:
I suspect the problem could be in the trailing comma ,
character in arguments of a function call. It's a relatively recent JS/ES feature that is very likely not supported by older version of Node (e.g. Node version 8 and maybe 10 too).
@luke-jia @alejandroBrb could you please try to remove the trailing comma on line loopback-connector/lib/sql.js:638
(e.g. by editing your local copy in node_modules
) and let us know if such change fixes the problem?
If it does, then it would be awesome if you could contribute the fix. See https://loopback.io/doc/en/contrib/code-contrib.html to get started.
Here is the relevant code, assuming we are talking about the latest version:
I suspect the problem could be in the trailing comma
,
character in arguments of a function call. It's a relatively recent JS/ES feature that is very likely not supported by older version of Node (e.g. Node version 8 and maybe 10 too).@luke-jia @alejandroBrb could you please try to remove the trailing comma on line
loopback-connector/lib/sql.js:638
(e.g. by editing your local copy innode_modules
) and let us know if such change fixes the problem?If it does, then it would be awesome if you could contribute the fix. See https://loopback.io/doc/en/contrib/code-contrib.html to get started.
I removed the commas and it worked.
"loopback": "^3.26.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^4.0.0",
"loopback-component-migrate": "^0.3.5",
"loopback-component-storage": "^3.2.0",
"loopback-connector-postgresql": "^3.6.1",
"loopback-connector-rest": "^2.1.0",
"loopback-context": "^3.1.0",
@Balthair94, thanks for trying it out. Would you like to submit a patch? Thanks.
Add "maxOfflineRequests": 20 in datasource.json
Node: 10.16.3
"loopback": "^3.22.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^6.2.0",
"loopback-connector-postgresql": "^3.4.0"
"postgres": {
"host": "${DB_HOST}",
"port": "${DB_PORT}",
"database": "${DB_NAME}",
"password": "${DB_PASSWORD}",
"name": "postgres",
"user": "${DB_USER_NAME}",
"connector": "postgresql",
"maxOfflineRequests": 20
}
@dhmlau After I upgrade the node from 7 to 8.9.0, the issue disappeared. However, I still recommend you to fix this compatible issue. Thanks.
Set number of maxOfflineRequests, then ok! I see the difference in tag@4.7.0
if (!(model in self._models)) {
return process.nextTick(function() {
done(new Error(g.f('Model not found: %s', model)));
});
}
and in tag@4.9.0
if (!this.dataSource.connected) {
// Prevent adding too many listeners to the 'connected' event on the datasource.
if (this.dataSource.listenerCount('connected') <
this.dataSource.getMaxOfflineRequests()) {
// allow this listener to be added to this event
return this.dataSource.once('connected', function() {
self.execute(sql, params, options, callback);
});
} else {
const limitReachedError = new Error(
g.f(
'Event listener limit reached. ' +
'Increase maxOfflineRequests value in datasources.json.',
),
);
callback(limitReachedError);
}
does number of maxOfflineRequests make sense? And how can we use the value?
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.
The minimum Node.js version required by LoopBack is 10.x. Node.js 10 does support trailing comma in function call arguments.
I am closing this issue as wont-fix.
How was this resolved? I get same error for oracle database
Unhandled error in GET /: 500 Error: Event listener limit reached. Increase maxOfflineRequests value in datasources.json. at Oracle.SQLConnector.execute (/app/node_modules/loopback-connector/lib/sql.js:580:33) at Promise (/app/node_modules/loopback-datasource-juggler/lib/datasource.js:2720:20)
Description/Steps to reproduce
loopback-connector/lib/sql.js:638 ), ^ SyntaxError: Unexpected token ) at createScript (vm.js:53:10) at Object.runInThisContext (vm.js:95:10) at Module._compile (module.js:543:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object. (/usr/src/microservice/caapp/node_modules/loopback-connector/index.js:12:47)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
Link to reproduction sandbox
Expected result
Additional information