@@ -29,17 +29,17 @@ var $arr = require('./array'),
29
29
* handlers that each {@link Database} object needs to set up.
30
30
*
31
31
* **Starting with v.4.7.0:**
32
- *
32
+ *
33
33
* If you create more than one {@link Database} object for the same connection, you will see the following warning
34
34
* in a development environment (when `NODE_ENV` = `development`):
35
- *
35
+ *
36
36
* `WARNING: Creating a duplicate database object for the same connection`.
37
- *
37
+ *
38
38
* And since every {@link Database} object needs to set up its own event listeners, you are likely to see the following
39
39
* warning in the console also:
40
- *
40
+ *
41
41
* `Warning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit`.
42
- *
42
+ *
43
43
* If you ever see any of those warnings, do not try increasing the limit, this won't help you.
44
44
* Instead, rectify your {@link Database} object initialization, so there is only one object per connection details.
45
45
* See the example provided below.
@@ -1214,8 +1214,11 @@ function checkForDuplicates(cn, config) {
1214
1214
var cnKey = JSON . stringify ( cn ) ;
1215
1215
if ( cnKey in dbObjects ) {
1216
1216
if ( ! config . options . noWarnings ) {
1217
+ // from the call stack, we take only lines starting with the client's
1218
+ // source code, and only those that contain a full path inside brackets,
1219
+ // indicating a reference to the client's source code:
1217
1220
var stack = new Error ( ) . stack . split ( '\n' ) . slice ( 4 ) . filter ( function ( line ) {
1218
- return line . match ( / \( .* ( \\ + | \/ + ) .* \) / ) ;
1221
+ return line . match ( / \( .* ( \\ + | \/ + ) .* \) / ) ; // contains \ or / inside ()
1219
1222
} ) . join ( '\n' ) ;
1220
1223
var msg = "WARNING: Creating a duplicate database object for the same connection." +
1221
1224
EOL + stack + EOL ;
0 commit comments