Skip to content
Snippets Groups Projects
Commit 78dc9470 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Don't log "symbol 'x' is not defined by script 'y'" error when terminating

When a JS environment (e.g. server, jsexec) is terminated, it's possible
that a require() script was being evaluated. But since termination would
abort that evaluation, it's not unexpected if a symbol ends up not being
defined before the require() script was terminated, so don't report an
error in that case.

Fix issue #681
parent f43e852a
No related branches found
No related tags found
No related merge requests found
...@@ -728,8 +728,10 @@ js_require(JSContext *cx, uintN argc, jsval *arglist) ...@@ -728,8 +728,10 @@ js_require(JSContext *cx, uintN argc, jsval *arglist)
if (!JS_IsExceptionPending(cx)) { if (!JS_IsExceptionPending(cx)) {
if (!JS_HasProperty(cx, exec_obj, property, &found) || !found) { if (!JS_HasProperty(cx, exec_obj, property, &found) || !found) {
if (TRUE) { //!js_IsTerminated(cx, exec_obj)) {
JSVALUE_TO_MSTRING(cx, argv[fnarg], filename, NULL); JSVALUE_TO_MSTRING(cx, argv[fnarg], filename, NULL);
JS_ReportError(cx,"symbol '%s' not defined by script '%s'", property, filename); JS_ReportError(cx,"symbol '%s' not defined by script '%s'", property, filename);
}
free(filename); free(filename);
free(property); free(property);
return(JS_FALSE); return(JS_FALSE);
......
...@@ -47,6 +47,20 @@ enum { ...@@ -47,6 +47,20 @@ enum {
,PROP_KEEPGOING ,PROP_KEEPGOING
}; };
JSBool js_IsTerminated(JSContext* cx, JSObject* obj)
{
js_callback_t* cb;
js_callback_t* top_cb;
if ((cb = (js_callback_t*)JS_GetPrivate(cx,obj)) == NULL)
return JS_FALSE;
for (top_cb=cb; top_cb->bg && top_cb->parent_cb; top_cb=top_cb->parent_cb) {
if(top_cb->terminated && *top_cb->terminated)
return JS_TRUE;
}
return top_cb->terminated && *top_cb->terminated;
}
static JSBool js_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp) static JSBool js_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{ {
jsval idval; jsval idval;
......
...@@ -1429,6 +1429,7 @@ extern "C" { ...@@ -1429,6 +1429,7 @@ extern "C" {
DLLEXPORT JSBool js_CommonOperationCallback(JSContext*, js_callback_t*); DLLEXPORT JSBool js_CommonOperationCallback(JSContext*, js_callback_t*);
DLLEXPORT void js_EvalOnExit(JSContext*, JSObject*, js_callback_t*); DLLEXPORT void js_EvalOnExit(JSContext*, JSObject*, js_callback_t*);
DLLEXPORT void js_PrepareToExecute(JSContext*, JSObject*, const char *filename, const char* startup_dir, JSObject *); DLLEXPORT void js_PrepareToExecute(JSContext*, JSObject*, const char *filename, const char* startup_dir, JSObject *);
DLLEXPORT JSBool js_IsTerminated(JSContext*, JSObject*);
DLLEXPORT char* js_getstring(JSContext *cx, JSString *str); DLLEXPORT char* js_getstring(JSContext *cx, JSString *str);
DLLEXPORT JSBool js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated); DLLEXPORT JSBool js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated);
DLLEXPORT JSBool js_clear_event(JSContext *cx, jsval *arglist, js_callback_t *cb, enum js_event_type et, int ididx); DLLEXPORT JSBool js_clear_event(JSContext *cx, jsval *arglist, js_callback_t *cb, enum js_event_type et, int ididx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment