apostrophecms / apostrophe-monitor

Monitors and restarts an Apostrophe app when your code, templates, etc. change. Like nodemon but much faster because it takes advantage of how Apostrophe works.
8 stars 1 forks source link

MongoError: Topology was destroyed #5

Open fredrikekelund opened 5 years ago

fredrikekelund commented 5 years ago

Very often, I'll run into this error when using apostrophe-monitor.

Unhandled rejection MongoError: Topology was destroyed
    at nextFunction (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb-core/lib/cursor.js:547:27)
    at Cursor.next [as _next] (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb-core/lib/cursor.js:701:3)
    at fetchDocs (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb/lib/cursor.js:857:10)
    at toArray (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb/lib/cursor.js:884:3)
    at Cursor.toArray (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb/lib/cursor.js:837:44)
    at self.mongoToArray (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/lib/modules/apostrophe-docs/lib/cursor.js:1427:20)
    at fn (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:746:34)
    at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:1213:16
    at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:166:37
    at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:706:43
    at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:167:37
    at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:1209:30
    at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:52:16
    at Immediate.<anonymous> (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:1206:34)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)

It happens after the application has restarted at least once. It doesn't seem to be connected to any particular database operation, ie. it can pop up when I'm not actively updating the database in any way. It also seems to not really have any effect – pages display correctly and I can still make updates.

I haven't debugged it very thoroughly, but here are some details about my setup that may be helpful:

macOS Mojave
MongoDB v4.2.0
apostrophe@2.98.1
apostrophe-monitor@2.0.5
boutell commented 5 years ago

I've seen this too. I think it is a timing issue in which one more usage of the previous database connection somehow occurs after the shutdown and restart. Come to think of it you might be able to find it with APOS_TRACE_DB=1. This will log a lot, including happy queries that happen afterwards, but the trace right before the error will probably be the relevant one.

Or maybe it's the sessions module making one last query too late, that's possible too.

On Wed, Oct 30, 2019 at 5:17 AM Fredrik Ekelund notifications@github.com wrote:

Very often, I'll run into this error when using apostrophe-monitor.

Unhandled rejection MongoError: Topology was destroyed

at nextFunction (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb-core/lib/cursor.js:547:27)

at Cursor.next [as _next] (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb-core/lib/cursor.js:701:3)

at fetchDocs (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb/lib/cursor.js:857:10)

at toArray (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb/lib/cursor.js:884:3)

at Cursor.toArray (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/mongodb/lib/cursor.js:837:44)

at self.mongoToArray (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/lib/modules/apostrophe-docs/lib/cursor.js:1427:20)

at fn (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:746:34)

at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:1213:16

at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:166:37

at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:706:43

at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:167:37

at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:1209:30

at /Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:52:16

at Immediate.<anonymous> (/Users/fredrik/Documents/GitHub/my-apos-site/node_modules/apostrophe/node_modules/async/lib/async.js:1206:34)

at runCallback (timers.js:705:18)

at tryOnImmediate (timers.js:676:5)

It happens after the application has restarted at least once. It doesn't seem to be connected to any particular database operation, ie. it can pop up when I'm not actively updating the database in any way. It also seems to not really have any effect – pages display correctly and I can still make updates.

I haven't debugged it very thoroughly, but here are some details about my setup that may be helpful:

macOS Mojave

MongoDB v4.2.0

apostrophe@2.98.1

apostrophe-monitor@2.0.5

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-monitor/issues/5?email_source=notifications&email_token=AAAH27P7HLDEEK4DL4CIRELQRFGK7A5CNFSM4JGV3YCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HVKYI4Q, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27NH5ZVQOWQJOGKFURDQRFGK7ANCNFSM4JGV3YCA .

--

THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his