Issue metadata
Sign in to add a comment
|
chrome.runtime.sendMessage responseCallback called with an argument on failures
Reported by
mathieu....@gmail.com,
Mar 1 2016
|
||||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.64 Safari/537.36 Steps to reproduce the problem: 1. call chrome.runtime.sendMessage with a responseCallback function to send a message to a non-installed extension id 2. observer arguments.length == 1 despite an error occurring Example: https://jsfiddle.net/favbjrt2/ What is the expected behavior? responseCallback is invoked with no arguments What went wrong? responseCallback was invoked with an undefined value for the first argument. WebStore page: Did this work before? Yes Chrome 48 Chrome version: 49.0.2623.64 Channel: beta OS Version: 10.0 Flash Version:
,
Apr 5 2016
I disagree, the published documentation says: "If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message." It specifically says "no arguments", not "a value of undefined". This is clearly an undocumented change in behavior. Regarding detection of errors, checking lastError to figure out if an error occurred at all is quite counter-intuitive. In JavaScript, errors are indicated by exceptions thrown if synchronous and errors in callback / promise rejections if async. I'll pass on not having the error object in the callback, but there should be a way to know the async operation failed straight from the callback params.
,
Apr 5 2016
That's indeed quite a strong statement in the documentation. I'll submit a patch to fix the callback in case anyone else is relying on it. The canonical way to detect errors in extensions is via chrome.runtime.lastError in the callback. If you develop Chrome extensions, you should use chrome.runtime.lastError to detect extension-specific errors (and if you blindly pass untrusted parameters to the functions, also use try-catch since a mismatch in function parameter types causes an error to be thrown synchronously).
,
Apr 6 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/ccb3bac625a150b6de7ed1855cfb3354f932792c commit ccb3bac625a150b6de7ed1855cfb3354f932792c Author: rob <rob@robwu.nl> Date: Wed Apr 06 00:22:54 2016 Call chrome.runtime.sendMessage's callback without arguments upon fail BUG= 590949 Review URL: https://codereview.chromium.org/1860953003 Cr-Commit-Position: refs/heads/master@{#385346} [modify] https://crrev.com/ccb3bac625a150b6de7ed1855cfb3354f932792c/extensions/renderer/resources/messaging.js
,
Apr 6 2016
|
|||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||
Comment 1 by rob@robwu.nl
, Apr 5 2016Status: WontFix (was: Unconfirmed)