diff --git a/src/sbbs3/js_global.c b/src/sbbs3/js_global.c
index f9c7726f1c643187f3eb0ebb4003b967a5931f00..a9a435d4892ce433e80e6eb1a3d5c9b05741d043 100644
--- a/src/sbbs3/js_global.c
+++ b/src/sbbs3/js_global.c
@@ -91,6 +91,7 @@ typedef struct {
 	JSScript*		script;
 	msg_queue_t*	msg_queue;
 	js_branch_t		branch;
+	JSErrorReporter error_reporter;
 } background_data_t;
 
 static void background_thread(void* arg)
@@ -108,6 +109,24 @@ static void background_thread(void* arg)
 	free(bg);
 }
 
+static void
+js_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
+{
+	background_data_t* bg;
+
+	if((bg=(background_data_t*)JS_GetContextPrivate(cx))==NULL)
+		return;
+
+	/* Use parent's context private data */
+	JS_SetContextPrivate(cx, JS_GetContextPrivate(bg->parent_cx));
+
+	/* Call parent's error reporter */
+	bg->error_reporter(cx, message, report);
+
+	/* Restore our context private data */
+	JS_SetContextPrivate(cx, bg);
+}
+
 static JSBool js_BranchCallback(JSContext *cx, JSScript* script)
 {
 	background_data_t* bg;
@@ -137,7 +156,6 @@ js_load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 	JSBool		success;
 	JSBool		background=JS_FALSE;
 	background_data_t* bg;
-	JSErrorReporter	reporter;
 
 	*rval=JSVAL_VOID;
 
@@ -183,12 +201,12 @@ js_load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 
 		js_CreateQueueObject(bg->cx, bg->obj, "parent_queue", bg->msg_queue);
 
-		/* Use the error reporter from the parent context */
-		reporter=JS_SetErrorReporter(cx,NULL);
-		JS_SetErrorReporter(cx,reporter);
-		JS_SetErrorReporter(bg->cx,reporter);
+		/* Save parent's error reporter (for later use by our error reporter) */
+		bg->error_reporter=JS_SetErrorReporter(cx,NULL);
+		JS_SetErrorReporter(cx,bg->error_reporter);
+		JS_SetErrorReporter(bg->cx,js_ErrorReporter);
 
-		/* Use the generic branch callback */
+		/* Set our branch callback (which calls the generic branch callback) */
 		JS_SetContextPrivate(bg->cx, bg);
 		JS_SetBranchCallback(bg->cx, js_BranchCallback);