Chrome shows RESULT_CODE_INVALID_CMDLINE_URL when other Chromium browsers work fine

Viewed 2160

I'm writing a WP plugin that makes changes to tags and categories. After making my selections and submitting the form, the page reloads and executes wp_set_post_categories and/or wp_set_post_terms.

It works fine even in other Chromium based browsers, but when I try it in Chrome, it throws the following error:

Error code: RESULT_CODE_INVALID_CMDLINE_URL

There's a "Learn more" link, but nothing happens when I click it.

After refreshing the page, I can see that my script did what it was supposed to do, but I'd like to eliminate this error if possible.

I found this support page about the error code, and I turned on logging to see if that would give me any clues, but I don't really know what to look for.

Please let me know if there is any additional info I can add that might lead to an answer. Thanks!

2 Answers

I don't know what might have caused your problem, but I know a problem that causes this error. So even if it is too late someone may benefit from it. I found your question when I was answering a related problem here. you can read it if you want, but in short this happens when an array of length infinity is created. (like a

stackoverflow

). If you want to regenerate such an issue you can use this js code below.

let arr = [];
let arrcounter = 13;
for (let x = 1; x <= arrcounter; x) {
    arr.push(x);
}

This is an infinite loop that adds an element to an array.

This might not be your exact problem, but I hope this helps.

I was running into this problem too, and I found in the end that my web app was running out of memory. So @EHM is right - an infinite loop that keeps adding to an array will eventually run out of memory and cause this issue.

But in my case, it was running out of memory because the js heap was not getting cleared after each page refresh. For testing purposes, I was running a puppeteer script that refreshed the page many times, and after 40 or so refreshes it would crash with the RESULT_CODE_INVALID_CMDLINE_URL error.

I'm not sure why chrome was not clearing the heap between refreshes, but this type of issue has been reported before under certain conditions, see this issue: https://bugs.chromium.org/p/chromium/issues/detail?id=113983. Without digging too much here into why it can happen, I will post here how to detect if your memory is getting out of control. You can use the chrome dev tools performance monitor, a built-in part of chrome dev tools:

enter image description here

The official docs on the performance monitor are here: https://developers.google.com/web/updates/2017/11/devtools-release-notes#perf-monitor

In case that link stops working, here are the basic steps:

  1. Open chrome dev tools while on your web site with a memory issue
  2. Press cmd-shift-P to open the command palette. Search for "Performance Monitor"
  3. Once the perf monitor is open, watch the heap size in real time. While watching the heap size, reproduce the condition that causes the RESULT_CODE_INVALID_CMDLINE_URL. You should see the heap size gradually increase until the error occurs.
  4. Now that you can see the memory leak happening, try to isolate what part of your code is causing a memory leak. Chrome dev tools has other tools to record heap usage and isolate which objects are being allocated. You may have an infinitely growing array, like @EHM mentioned, or a number of other issues. In my case, Chrome didn't seem to be releasing certain DOM nodes between refreshes. I was able to fix my script by navigating to a different domain between refreshes, which caused chrome to correctly release all the DOM nodes. To learn all about finding memory issues in chrome, read their article on the topic here: https://developers.google.com/web/tools/chrome-devtools/memory-problems
Related