ResourceWatcher can call onAvailable callbacks with an empty array of resources
Categories
(DevTools :: Framework, task, P3)
Tracking
(firefox82 fixed)
Tracking | Status | |
---|---|---|
firefox82 | --- | fixed |
People
(Reporter: jdescottes, Assigned: jdescottes)
References
Details
Attachments
(2 files)
After Bug 1660268, the resource watcher might call onResourceAvailable without any resource because of cached resources:
async _forwardCachedResources(resourceTypes, onAvailable) {
await onAvailable(
this._cache.filter(resource =>
resourceTypes.includes(resource.resourceType)
)
);
}
If the cache doesn't contain any resource matching the provided types, onAvailable is called with an empty array.
This should not really be an issue for production code, as we usually loop on resources before doing anything. But it still might be surprising when writing less critical code (eg test helpers).
I know I stumbled on it while updating our waitForResourceOnce
helper and it took me some time to investigate.
Comment 1•4 years ago
|
||
Oh yes, I saw that, and a similar things is happening on the server side if there is no cached/existing resources.
Comment 2•4 years ago
|
||
For example, here:
https://searchfox.org/mozilla-central/source/devtools/server/actors/resources/console-messages.js#73-88
if messages is empty, we will still emit an available event. We should probably avoid emitting the rdp event from the target and watcher methods.
Assignee | ||
Comment 3•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 4•4 years ago
|
||
(In reply to Alexandre Poirot [:ochameau] from comment #2)
For example, here:
https://searchfox.org/mozilla-central/source/devtools/server/actors/resources/console-messages.js#73-88
if messages is empty, we will still emit an available event. We should probably avoid emitting the rdp event from the target and watcher methods.
Oh thanks for the info, I'll try to go over the server side resources as well!
Assignee | ||
Comment 5•4 years ago
|
||
Depends on D89609
Comment 7•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/7ca10521eee1
https://hg.mozilla.org/mozilla-central/rev/e9d1bafa8602
Description
•