Skip to content

Commit bec6991

Browse files
committed
Fix types
Maybe?
1 parent c2ab360 commit bec6991

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

packages/realm-server/fastboot.ts

+8-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
type RunnerOpts,
88
} from '@cardstack/runtime-common/search-index';
99
import { JSDOM } from 'jsdom';
10-
import * as Sentry from '@sentry/node';
10+
import { type ErrorReporter } from '@cardstack/runtime-common/realm';
1111

1212
const appName = '@cardstack/host';
1313
export async function makeFastBootIndexRunner(
@@ -16,22 +16,19 @@ export async function makeFastBootIndexRunner(
1616
): Promise<{ getRunner: IndexRunner; distPath: string }> {
1717
let fastboot: FastBootInstance;
1818
let distPath: string;
19+
20+
let globalWithErrorReporter = global as typeof globalThis & {
21+
__boxelErrorReporter: ErrorReporter;
22+
};
23+
1924
if (typeof dist === 'string') {
2025
distPath = dist;
2126
fastboot = new FastBoot({
2227
distPath,
2328
resilient: false,
2429
buildSandboxGlobals(defaultGlobals: any) {
25-
let sentryScope = Sentry.getCurrentScope();
26-
console.log('sentry scope', sentryScope);
27-
// debugger;
28-
console.log(
29-
'does error reporter exist when setting up fastboot v1',
30-
globalThis.errorReporter,
31-
);
3230
return Object.assign({}, defaultGlobals, {
33-
errorReporter: globalThis.errorReporter,
34-
__SENTRY__: globalThis.__SENTRY__,
31+
__boxelErrorReporter: globalWithErrorReporter.__boxelErrorReporter,
3532
URL: globalThis.URL,
3633
Request: globalThis.Request,
3734
Response: globalThis.Response,
@@ -47,12 +44,8 @@ export async function makeFastBootIndexRunner(
4744
appName,
4845
dist,
4946
(defaultGlobals: any) => {
50-
console.log(
51-
'does error reporter exist when setting up fastboot v2',
52-
globalThis.errorReporter,
53-
);
5447
return Object.assign({}, defaultGlobals, {
55-
errorReporter: globalThis.errorReporter,
48+
__boxelErrorReporter: globalWithErrorReporter.__boxelErrorReporter,
5649
URL: globalThis.URL,
5750
Request: globalThis.Request,
5851
Response: globalThis.Response,

packages/runtime-common/realm.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1676,21 +1676,23 @@ function lastModifiedHeader(
16761676
) as {} | { 'last-modified': string };
16771677
}
16781678

1679-
type ErrorReporter = (error: Error) => void;
1679+
export type ErrorReporter = (error: Error) => void;
16801680

1681-
let errorReporter: ErrorReporter;
1681+
let globalWithErrorReporter = global as typeof globalThis & {
1682+
__boxelErrorReporter: ErrorReporter;
1683+
};
16821684

16831685
export function setErrorReporter(reporter: ErrorReporter) {
16841686
console.log('setting an error reporter', reporter);
1685-
globalThis.errorReporter = reporter;
1687+
globalWithErrorReporter.__boxelErrorReporter = reporter;
16861688
}
16871689

16881690
export function reportError(error: Error) {
16891691
console.log('in report error');
16901692
console.log(error);
1691-
if (globalThis.errorReporter) {
1693+
if (globalWithErrorReporter.__boxelErrorReporter) {
16921694
console.log('error reporter exists');
1693-
globalThis.errorReporter(error);
1695+
globalWithErrorReporter.__boxelErrorReporter(error);
16941696
} else {
16951697
console.log('error reporter does not exist');
16961698
}

0 commit comments

Comments
 (0)