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
Add FastBoot support #77
Comments
I'll probably end up tackling this within the next week or so, but just in case someone gets here first. The above fix is no longer recommended and will not work in fastboot rc.1. New method here: https://gist.github.com/kratiahuja/d22de0fb1660cf0ef58f07a6bcbf1a1c#using-processenvember_cli_fastboot-to-run-import-in-browser-build |
Any news on this front? Are none of the 3 PRs applicable since fastboot rc.1? |
I haven't had a chance to in our app yet, but the problem is that most fastboot fixes just skip it when in fastboot, in this case I think we actually want to use it in fastboot and client side - but it requires some changes to how events are sent to sentry. More info is here: getsentry/raven-node#303 |
With the recent changes of Sentry packages management (addition of scoped packages), I wonder if this issue could be solved more easily than what could be done a year ago. |
Hi. What's the state of FastBoot support? |
@viniciussbs doesn't exist |
@Turbo87 Can you tell if the app crashes on FastBoot land or it just does not report the errors? |
We're working around this using fastboot-app-server by setting up a Node Sentry client in our Express It's not ideal, since we aren't able to use most Sentry's built-in tooling to extract metadata from the request, but at least these errors aren't just silently being logged and forgotten. In const FastBootAppServer = require('fastboot-app-server');
const serverOptions = { <whatever options the FB app server needs> }
if (process.env.SENTRY_DSN) {
Sentry = require('@sentry/node');
Sentry.init({ dsn: process.env.SENTRY_DSN });
serverOptions.sandboxGlobals = { FastBootRaven: Sentry };
}
const server = new FastBootAppServer(serverOptions);
server.start(); Instance initializer in the Ember app: /* Sets up Ember's global error handler in FastBoot to use a Raven instance
* provided in our fastboot-server via the Fastboot sandbox.
*/
export default {
name: 'app-error-handler',
initialize(appInstance) {
let oldOnError;
if (Ember.onerror === 'undefined' && typeof FastBoot !== 'undefined') {
/* This replicates the default logging Ember.onerror implementation
* included with FastBoot, since that implementation isn't installed
* when any existing Ember.onerror has been set.
*/
oldOnError = function(err) {
const errorMessage = `There was an error running your app in fastboot. More info about the error: \n ${err.stack || err}`;
console.error(errorMessage);
};
} else {
oldOnError = Ember.onerror; // eslint-disable-line ember-suave/no-direct-property-access
}
Ember.onerror = (error) => {
if (typeof FastBootRaven !== 'undefined') {
const fastboot = appInstance.lookup('service:fastboot');
const req = fastboot.request;
const { protocol, headers } = req;
const host = req.hostname || req.host || headers.host || '<no host>';
const originalUrl = (req.originalUrl || req.url || req.path);
const absoluteUrl = `${protocol}://${host}${originalUrl}`;
FastBootRaven.withScope(function(scope) {
scope.setTag('url', absoluteUrl);
scope.setExtra('query_params', req.query_params);
FastBootRaven.captureException(error);
});
}
if (typeof(oldOnError) === 'function') { oldOnError.call(Ember, error); }
};
},
}; |
For some reason Using ember 3.15 with octane. Configured an error route, Ember automatically handles errors using this route: # app/routes/error.js
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class ErrorRoute extends Route {
@service('error-handler') errorHandlerService;
// setupController function receives the error exception as a parameter
setupController(_controller, error) {
this.coreErrorHandlerService.handleServerSideError(error);
super.setupController(...arguments);
}
}
A service to handle errors: # app/services/error-handler.js
import Service from '@ember/service';
import { inject as service } from '@ember/service';
export default class errorHandlerService extends Service {
@service('fastboot') fastboot;
handleServerSideError(error) {
if (!this.fastboot.isFastBoot) return;
if (typeof FastBootRaven !== 'undefined') {
const req = fastboot.request;
const { protocol, headers } = req;
const host = req.hostname || req.host || headers.host || '<no host>';
const originalUrl = (req.originalUrl || req.url || req.path);
const absoluteUrl = `${protocol}://${host}${originalUrl}`;
// const userScope = this.userScope; // If you have an user scope you can get from service property here
FastBootRaven.withScope(function(scope) {
scope.setTag('url', absoluteUrl);
scope.setExtra('query_params', req.query_params);
// scope.setUser(userScope);
FastBootRaven.captureException(error);
});
}
} And of course, I've setted my |
Currently it'll always try to
app.import
the Raven JS library, even in FastBoot (server side).This results in the below error for every request:
We should wrap the
app.import
with a check forprocess.env.EMBER_CLI_FASTBOOT
inindex.js
:The text was updated successfully, but these errors were encountered: