slide-drive icon indicating copy to clipboard operation
slide-drive copied to clipboard

Attempting to save an image-rich presentation causes an error from Mongo

Open banksJeremy opened this issue 12 years ago • 2 comments

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.

banksJeremy avatar Jun 14 '12 18:06 banksJeremy

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.

banksJeremy avatar Jun 14 '12 18:06 banksJeremy

Filed upstream: t1603

banksJeremy avatar Jun 18 '12 18:06 banksJeremy