@@ -14,15 +14,16 @@ declare global {
1414 }
1515}
1616
17- window . _gatsbyEvents = window . _gatsbyEvents || [ ]
17+ // Use `self` here instead of `window` so it works in non-window environments (like Workers)
18+ self . _gatsbyEvents = self . _gatsbyEvents || [ ]
1819
1920export function clearCompileError ( ) : void {
20- window . _gatsbyEvents . push ( [ `FAST_REFRESH` , { action : `CLEAR_COMPILE_ERROR` } ] )
21+ self . _gatsbyEvents . push ( [ `FAST_REFRESH` , { action : `CLEAR_COMPILE_ERROR` } ] )
2122}
2223
2324export function clearRuntimeErrors ( dismissOverlay : boolean ) : void {
2425 if ( typeof dismissOverlay === `undefined` || dismissOverlay ) {
25- window . _gatsbyEvents . push ( [
26+ self . _gatsbyEvents . push ( [
2627 `FAST_REFRESH` ,
2728 { action : `CLEAR_RUNTIME_ERRORS` } ,
2829 ] )
@@ -34,7 +35,7 @@ export function showCompileError(message): void {
3435 return
3536 }
3637
37- window . _gatsbyEvents . push ( [
38+ self . _gatsbyEvents . push ( [
3839 `FAST_REFRESH` ,
3940 {
4041 action : `SHOW_COMPILE_ERROR` ,
@@ -48,7 +49,7 @@ export function showRuntimeErrors(errors): void {
4849 return
4950 }
5051
51- window . _gatsbyEvents . push ( [
52+ self . _gatsbyEvents . push ( [
5253 `FAST_REFRESH` ,
5354 {
5455 action : `SHOW_RUNTIME_ERRORS` ,
@@ -66,7 +67,7 @@ export function isWebpackCompileError(error): boolean {
6667
6768export function handleRuntimeError ( error ) : void {
6869 if ( error && ! isWebpackCompileError ( error ) ) {
69- window . _gatsbyEvents . push ( [
70+ self . _gatsbyEvents . push ( [
7071 `FAST_REFRESH` ,
7172 {
7273 action : `HANDLE_RUNTIME_ERROR` ,
0 commit comments