From dbe7afb8a245adb90c24e5716d9cf2607b351504 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 1 May 2019 14:35:39 +0800 Subject: [PATCH 1/2] Don't throw on empty registered headless task --- Libraries/ReactNative/AppRegistry.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index 5e10af2f6b03b3..a88e9a68e9e83e 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -260,7 +260,11 @@ const AppRegistry = { startHeadlessTask(taskId: number, taskKey: string, data: any): void { const taskProvider = taskProviders.get(taskKey); if (!taskProvider) { - throw new Error(`No task registered for key ${taskKey}`); + console.warn( + `No task registered for key ${taskKey}`, + ); + NativeModules.HeadlessJsTaskSupport.notifyTaskFinished(taskId); + return; } taskProvider()(data) .then(() => From 543de0271a6fa126efab5cc9108b6e35053b048e Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 1 May 2019 15:30:17 +0800 Subject: [PATCH 2/2] Improve code style --- Libraries/ReactNative/AppRegistry.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index a88e9a68e9e83e..e4b8468633b40a 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -260,9 +260,7 @@ const AppRegistry = { startHeadlessTask(taskId: number, taskKey: string, data: any): void { const taskProvider = taskProviders.get(taskKey); if (!taskProvider) { - console.warn( - `No task registered for key ${taskKey}`, - ); + console.warn(`No task registered for key ${taskKey}`); NativeModules.HeadlessJsTaskSupport.notifyTaskFinished(taskId); return; }