Bug 1579654 - Use old set of scripts if reparsing for breakpoint positions fails, r=jlast. a=lizzard
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 16 Sep 2019 03:17:23 +0000
changeset 555235 eaf5ba87c7fcafc0ace60fc7a69f67452032c274
parent 555234 1ee62510b8ebfce59f516dcf56e0e2e52206fafd
child 555236 ded64553b007ef8496356b278f22bef0720b78f2
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast, lizzard
bugs1579654
milestone70.0
Bug 1579654 - Use old set of scripts if reparsing for breakpoint positions fails, r=jlast. a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D45965
devtools/server/actors/source.js
--- a/devtools/server/actors/source.js
+++ b/devtools/server/actors/source.js
@@ -394,28 +394,32 @@ const SourceActor = ActorClassWithSpec(s
     // been GC'ed as well. In this case we reparse the source and generate a new
     // and complete set of scripts to look for the breakpoint positions.
     // Note that in some cases like "new Function(stuff)" there might not be a
     // top level non-function script, but if there is a non-function script then
     // it must be at the top level and will keep all other scripts in the source
     // alive.
     const isWasm = this._source.introductionType === "wasm";
     if (!isWasm && !scripts.some(script => !script.isFunction)) {
-      scripts.length = 0;
-      function addScripts(script) {
-        scripts.push(script);
-        script.getChildScripts().forEach(addScripts);
-      }
+      let newScript;
       try {
-        addScripts(this._source.reparse());
+        newScript = this._source.reparse();
       } catch (e) {
         // reparse() will throw if the source is not valid JS. This can happen
         // if this source is the resurrection of a GC'ed source and there are
         // parse errors in the refetched contents.
       }
+      if (newScript) {
+        scripts.length = 0;
+        function addScripts(script) {
+          scripts.push(script);
+          script.getChildScripts().forEach(addScripts);
+        }
+        addScripts(newScript);
+      }
     }
 
     const positions = [];
     for (const script of scripts) {
       // This purely a performance boost to avoid needing to build an array
       // of breakable points for scripts when we know we don't need it.
       if (
         script.startLine > endLine ||