[BUG] Open this project's Assets page and your Glitch editor will crash

After doing some testing with how Glitch’s assets work, I was able to create an asset that will completely crash your Glitch editor when you open the Assets tab.

(The way I discovered this was not intentional, I was just testing some code in the console using the application object)

First, create a new project and run this code in the console:

application.newAsset({
  name: "chrome.png",
  url: "https://cdn.glitch.global/034c54c9-da3c-4cd1-876f-1564a4effdfc/chrome.png",
});
application.renameAsset({
  url: "https://cdn.glitch.global/034c54c9-da3c-4cd1-876f-1564a4effdfc/chrome.png"}, {
  url: "https://cdn.glitch.global/034c54c9-da3c-4cd1-876f-1564a4effdfc/example.png"
}) // this is just an example, I don't think this format is specifically needed to cause the crash

This adds the following lines to your .glitch-assets:

{"name":"chrome.png","url":"https://cdn.glitch.global/034c54c9-da3c-4cd1-876f-1564a4effdfc/chrome.png"}
{"deleted":true}
{"url":"https://cdn.glitch.global/a749211c-fb5c-4403-a856-e741eeaf9946/[object Object]","name":{"url":"https://cdn.glitch.global/034c54c9-da3c-4cd1-876f-1564a4effdfc/example.png"}}

Now, if you ever open the Assets tab again, it will crash your editor with this message in the console:

TypeError: l.match is not a function

I was able to get around this by resetting the .glitch-assets file myself, but it’s pretty cool and I wanted to report it. It has a ton of troll potential tho.

Solution: Add try ... catch ... to the assets rendering code that if an error is thrown will instead of crashing the whole editor just show a message in the assets page saying something like “Unable to render assets: Invalid or corrupted .glitch-assets file” instead of crashing the whole editor.

POC: ~assets-crasher > open assets tab

Note: I think this works with any invalid .glitch-assets file (you don’t need to use the code above with the console), but I’m not sure

boom

1 Like

I think this is less a standard bug and more a “don’t run this kind of code” PSA, but I’ll share with the team nonetheless!

3 Likes

the thing is, it won’t crash only your assets tab - anyone that opens it, having ran the code or not, will also get their editor crashed

Just their editor when they open that project though, right? (I’m just trying to see how bad this actually is)

1 Like

this is not rly that bad lol, yes it’s just the editor and it’s when they open the assets tab, not the project

I think it’s fixed now
Edit: no it isn’t

  1. deleted entry missing name?
  2. would this not crash other collaborators’ and viewers’ editors? the . glitch-assets file would be synced to everyone, right?
1 Like

I think this only happens when you open the assets pane, so yes it’ll crash everyone’s view but only if they open the assets page

Whoa! Not fixed, but that is awesome!

2 Likes

it’s got some troll potential and just a cool lil bug

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.