slide-drive
slide-drive copied to clipboard
Attempting to save an image-rich presentation causes an error from Mongo
The error that shows up in Mongo's log is vague...
Assertion: 10334:Invalid BSONObj size: 21942433
... but it looks like Mongo has a maximum document size the defaults to 16MB and I might be hitting due to having a lot of embedded images.
Butter keeps waiting for a response from Mongo that never comes, so it never closes the connection to the browser, causing a silent failure from the user's perspective.
Inside the handler for app.post('/api/project/:id?', ...)
in butter/cornfield/app.js
I replaced
doc.save();
res.json({ error: 'okay', project: proj });
with
doc.save(function (err) {
if ( !err ) {
res.json({ error: 'okay', project: proj });
} else {
res.json( {error: 'internal db error' }, 500 );
}
});
to fail better. (jeremybanks/butter@4eececbf3150bfdaf69018812b4aad4cc2d9cf2e)
This works, and now I'm confused why the failure left a connection open. I'd think that .save()
would be async and return instantly, so res.json(...)
would be called and close the connection in either case. Maybe it's not async? Weird.
Filed upstream: t1603