Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
webapp
webapp
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 684
    • Issues 684
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 26
    • Merge requests 26
  • Requirements
    • Requirements
    • List
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gitter
  • webappwebapp
  • Merge requests
  • !2133

Merged
Created Feb 18, 2021 by Eric Eastwood@MadLittleModsOwner

Stop Bluebird promise created but not returned warning when sending a message in a room

  • Overview 1
  • Commits 1
  • Pipelines 2
  • Changes 2

Stop Bluebird promise created but not returned warning when sending a message in a room (around the Gitter Matrix bridge).

Learned that I need to check up, down, and around the stack trace given to see where you forgot to return the promise. This one wasn't as obvious to me and thought it was possibly a problem with Mongoose itself which people have found problems in around the callbacks -> https://stackoverflow.com/q/39135678/796832 - That issue also mentions mongoose/lib/query.js which matched my stack trace so it seemed applicable.

The problem ended up being the the async onDataChange which is used as an event listener -> modules/matrix-bridge/lib/gitter-bridge.js#L25-29. That actual problem spot isn't even listed in the stack trace. The async function(which returns a promise behind the scenes) doesn't like getting fired and forgotten as a callback.

  • https://stackoverflow.com/q/42079265/796832 (this question got me looking at my trace closer)
  • https://stackoverflow.com/q/51773343/796832
  • https://stackoverflow.com/q/37861736/796832

The trace is very sparse and doesn't give enough info by default:

$ npm start

...
// Send a message in a room bridged to Matrix

(node:13460) Warning: a promise was created in a handler at domain.js:126:23 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (C:\Users\MLM\Documents\GitLab\webapp\node_modules\bluebird\js\release\promise.js:103:10)

But if you add --trace-warnings to the Node.js process, it gives the full stack trace. I added the --trace-warnings-node option to our start utility which will add --trace-warnings to the Node.js process. Similar to what we already do for the --inspect flag.

$ npm start -- --trace-warnings-node

...
// Send a message in a room bridged to Matrix

(node:16928) Warning: a promise was created in a handler at domain.js:126:23 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (C:\Users\MLM\Documents\GitLab\webapp\node_modules\bluebird\js\release\promise.js:103:10)
    at model.Query.exec (C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\lib\query.js:2294:17)
    at Object.findById (C:\Users\MLM\Documents\GitLab\webapp\modules\rooms\lib\troupe-service.js:44:42)
    at isGitterRoomIdAllowedToBridge (C:\Users\MLM\Documents\GitLab\webapp\modules\matrix-bridge\lib\gitter-utils.js:21:42)
    at GitterBridge.handleChatMessageCreateEvent (C:\Users\MLM\Documents\GitLab\webapp\modules\matrix-bridge\lib\gitter-bridge.js:85:35)
    at GitterBridge.onDataChange (C:\Users\MLM\Documents\GitLab\webapp\modules\matrix-bridge\lib\gitter-bridge.js:44:22)
    at EventEmitter.emit (events.js:203:15)
    at EventEmitter.emit (domain.js:448:20)
    at Object.dataChange2 (C:\Users\MLM\Documents\GitLab\webapp\modules\appevents\lib\app-events.js:137:25)
    at Object.<anonymous> (C:\Users\MLM\Documents\GitLab\webapp\server\services\live-collection-handlers\live-collection-chats.js:12:15)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
    at serializeChatToRoom (C:\Users\MLM\Documents\GitLab\webapp\server\services\live-collection-handlers\live-collection-chats.js:11:57)
    at Object.create (C:\Users\MLM\Documents\GitLab\webapp\server\services\live-collection-handlers\live-collection-chats.js:18:12)
    at EventEmitter.<anonymous> (C:\Users\MLM\Documents\GitLab\webapp\server\services\live-collection-handlers\index.js:46:46)
    at EventEmitter.emit (events.js:198:13)
    at EventEmitter.emit (domain.js:448:20)
    at Object.onCreate (C:\Users\MLM\Documents\GitLab\webapp\server\services\persistence-service-events.js:28:29)
    at model.<anonymous> (C:\Users\MLM\Documents\GitLab\webapp\modules\persistence-utils\lib\mongoose-utils.js:99:46)
    at model.<anonymous> (C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\lib\schema.js:1100:8)
    at next_ (C:\Users\MLM\Documents\GitLab\webapp\node_modules\hooks-fixed\hooks.js:86:35)
    at fnWrapper (C:\Users\MLM\Documents\GitLab\webapp\node_modules\hooks-fixed\hooks.js:186:8)
    at C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\lib\model.js:3388:16
    at C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\lib\model.js:233:5
    at C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\lib\model.js:139:7
    at timingCallback (C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongodb-perf-wrapper\lib\wrap.js:69:37)
    at timingCallback (C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongodb-perf-wrapper\lib\wrap.js:69:37)
    at C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\node_modules\mongodb\lib\collection.js:523:5
    at C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\node_modules\mongodb\lib\collection.js:701:5
    at handleCallback (C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\node_modules\mongodb\lib\utils.js:96:56)
    at C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\node_modules\mongodb\lib\bulk\unordered.js:473:9
    at handleCallback (C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\node_modules\mongodb\lib\utils.js:96:56)
    at resultHandler (C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\node_modules\mongodb\lib\bulk\unordered.js:420:5)
    at C:\Users\MLM\Documents\GitLab\webapp\node_modules\mongoose\node_modules\mongodb-core\lib\connection\pool.js:455:18
    at process._tickCallback (internal/process/next_tick.js:61:11)
Edited Feb 18, 2021 by Eric Eastwood
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: fix-bluebird-promise-created-not-returned-warning-when-sending-message-to-matrix