Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger.arm() does not work on server #11

Open
arggh opened this issue Nov 17, 2016 · 3 comments
Open

logger.arm() does not work on server #11

arggh opened this issue Nov 17, 2016 · 3 comments
Labels

Comments

@arggh
Copy link
Contributor

arggh commented Nov 17, 2016

Calling logger.arm() on the server does not seem to work as described in README.

Both client and server applications may capture exception stack traces and log them for plain errors (window.onerror handling) and exception reporting. This is triggers by the logger.arm() method, and can be disabled by the logger.disarm() method.

Example

/server/main.js

import { MongodbSender, ServerLogger, LeveledStrategy, MeteorUserProcessor } from 'filog';

// Initialize FiLog logger
const sender = new MongodbSender(Mongo, 'logger');
logger = new ServerLogger(
  new LeveledStrategy(sender, sender, sender),
  WebApp);
logger.processors.push(new MeteorUserProcessor());
logger.arm();

/server/some/other/directory/file.js

callNonExistentFunction();

This does not produce a log entry in the MongoDB's collection logger, instead, it just logs to console. The same procedure on the client does produce a log entry.

@fgm
Copy link
Owner

fgm commented Nov 18, 2016

Confirmed: this was planned, but in its current implementation relying on csnover/TraceKit, the stacks are only captured on browsers. The alternative, occ/TraceKit, rejected including Node support too.

Looking into https://github.com/v8/v8/wiki/Stack%20Trace%20API to see what it would entail. If you have any idea, I'm all ears.

@fgm
Copy link
Owner

fgm commented Nov 19, 2016

So I did various tests on the server side and it is indeed simple to make arm() work for top-level code by listening to the uncaughtException Error event. However:

  • this means we catch situations where there is no real way to know if continuing makes any sense. I think arm() could take an optional exit code parameter and set process.exitCode if it is not null, allowing exit as soon as all callbacks - including the logging action itself - are over.
  • Meteor creates new execution contexts where it catches "uncaught" exceptions itself and exits: see how timers.js#bindAndCatch() used Meteor.bindEnvironment(), and is used by Meteor.setTimeout(), Meteor.setInterval(), and Meteor.defer(). In such cases the error does not bubble up to the logger as Meteor silences the exception by just reporting on it and continuing. Monkey-patching this would be quite fragile.

Any idea ?

@fgm fgm added the bug label Nov 19, 2016
fgm added a commit that referenced this issue Nov 21, 2016
fgm added a commit that referenced this issue Nov 21, 2016
@fgm
Copy link
Owner

fgm commented Nov 24, 2016

Interesting and possibly useful article about errors: https://airbrake.io/blog/javascript-error-handling/javascript-error-hierarchy

fgm added a commit that referenced this issue Dec 2, 2016
fgm added a commit that referenced this issue Mar 6, 2017
fgm added a commit that referenced this issue Mar 23, 2017
fgm added a commit that referenced this issue Mar 23, 2017
fgm added a commit that referenced this issue Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants