Skip to content

Instantly share code, notes, and snippets.

@crabdancing
Last active December 21, 2021 05:25
Show Gist options
  • Save crabdancing/7fe1a31a6cf5eadfcc1bd1103fb25502 to your computer and use it in GitHub Desktop.
Save crabdancing/7fe1a31a6cf5eadfcc1bd1103fb25502 to your computer and use it in GitHub Desktop.
Getting SpyJS to work on some systems is difficult. Here's how to do it.

I use Arch Linux, with KDE. I've spent the past TWO HOURS trying to get SpyJS -- a proxy-based JS debugging tool -- to work. It originally did not work, giving an incredibly vague 'No events captured' message, and no error. Because it's a proxy -- essentially a workaround for lack of proper integration -- it can't tell what's gone wrong, if it's on the browser's side.

So, modern browsers apparently try to 'intelligently' ignore proxy settings if you're accessing localhost. Did you know this? I sure didn't.

They do this silently with no warning anywhere -- even though they ostensibly do this for security reasons.

There's a workaround where you replace localhost with local, and add local to your /etc/hosts. This workaround works for both Chromium and Firefox, in my tests, but gives you a 404 when you try to access the local dev server -- because SpyJS is paranoid and will reject it if it's accessing via the wrong domain.

If you want to use Chromium/Chrome, with localhost proxying you can supposedly fix it via --proxy-bypass-list -- but that doesn't work because Chromium is trash made by a trash company for losers.

So, you have to use Firefox, as far as I can tell. Enable network.proxy.allow_hijacking_localhost on the about:config page, then manually configure the proxy -- an HTTP localhost proxy, with port 3542 by default. Of course, the HTTP proxy settings can be accessed via about:preferences -> General -> Network Settings.

TLDR

You getting No events captured on WebStorm+SpyJS? Google hates you. Use Firefox. Enable the 'proxy localhost hijacking' thingy in about:config Manually set proxy to localhost, with port 3542. I spent 2 fucking hours to figure this out. You're welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment