KkZsc opened a new issue, #10253:
URL: https://github.com/apache/skywalking/issues/10253

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache SkyWalking Component
   
   NodeJS Server Side Agent (apache/skywalking-nodejs)
   
   ### What happened
   
   When `skywalking-nodejs` is used in the project, `mongoose` will have errors 
like this:
   `dict_info_1.default.findOne(...).lean is not a function`.
   and the source code is like this:
   `const result = await DictInfoModel.findOne({ dict_key: 'xxx' 
}).lean().exec();`
   
   I tried to browse through the `skywalking-nodejs` code and found that there 
is a piece of code like this in the 
[MongoosePlugin.ts](https://github.com/apache/skywalking-nodejs/blob/master/src/plugins/MongoosePlugin.ts#L133)
 file:
   ```
   if (!hasCB) {
     if (ret && typeof ret.then === 'function') {
       // generic Promise check
       ret = wrapPromise(span, ret);
     } else {
       // no callback passed in and no Promise or Cursor returned, play it safe
       span.stop();
   
       return ret;
     }
   }
   ```
   `ret` is changed to `Promise` at `ret = wrapPromise(span, ret);`, no longer 
has `mongoose` methods.
   
   And this is the version information I use:
   mongoose: ^4.7.3
   skywalking-nodejs: 0.6.0
   
   ### What you expected to happen
   
   `mongoose` can run correctly
   
   ### How to reproduce
   
   1. Create a project using mongoose
   2. Install `skywalking-nodejs`
   3. Write `mongoose` query code: `tableName.findOne().lean().exec()`
   4. Run app and will see an error in the console
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to