Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Pre-fill the code field in the playground on error #28

Closed
Matsuuu opened this issue Jun 18, 2021 · 8 comments
Closed

Comments

@Matsuuu
Copy link
Contributor

Matsuuu commented Jun 18, 2021

It would be a nice user experience if, on error, as we get provided the playground link, it would have the parameters so that the code part is pre-filled with the contents of the file that caused the error.

This would make it easier and less cumbersome to submit bug reports.

It would mean that we need to add the source to the withErrorHandling function, and then parse the text property of the object.

What might make this ticket harder is if all of the use cases can't access the file responsible. But in these cases we could maybe just not generate it?

@thepassle
Copy link
Member

thepassle commented Jun 18, 2021

We should be able to do something like this. The module's AST has a .text property on the root node of the AST (the SourceFile node): https://astexplorer.net/#/gist/9b8066d5273d00c85a6a255a28c74958/d763625adece6398d34f276d714046e5ecfe5509

One problem here is that I think the playground can only handle a source file of a certain size because we call const decoded = decodeURIComponent(atob(source)); in the playground, where source comes from the url params. It'd suck if we get repro urls that dont work. Maybe we need to find out the exact length that decodeURIComponent/atob can handle, and skip if its too long

@Matsuuu
Copy link
Contributor Author

Matsuuu commented Jun 18, 2021

Good point!

I'll have to look into the subject, and will look into implementing this in the following week(s)

@Matsuuu
Copy link
Contributor Author

Matsuuu commented Jun 21, 2021

I did a quick test doing this, and threw a 400 line component at this. Javascript atob and decodeURIComponent can easily handle these, at least in node, but the URL itself becomes just too big for the browser to handle.

We could

a) Ditch the idea
or
b) Limit it to a managable URL size, in which case the max file length would be something like 200 lines max?

@Matsuuu
Copy link
Contributor Author

Matsuuu commented Jun 21, 2021

An idea I was thinking about was a url shortening service, or a quick api (firebase or custom etc.) to save the hash to and load it from, but as the playground currently stands it's only a frontend, and I'd advice against hosting out own error handling site just for this niche

@thepassle
Copy link
Member

Hm, yeah. Maybe we're overthinking things a bit 😅 We could do something like if(sourceFile.length < someAmountOfChars) generatePlaygroundUrl(), but on the other hand... I think the error reporting and issue creation process should already probably be straightforward enough. Maybe we leave the idea for now and if it turns out to be a problem in the future we can always revisit it. What do you think?

@Matsuuu
Copy link
Contributor Author

Matsuuu commented Jun 21, 2021

Yeah let's do that. It would be more of a confusion to the end user why sometimes it generates and sometimes it doesn't.

Maybe if this pops up later, we can implement something around it :)

@Matsuuu Matsuuu closed this as completed Jun 21, 2021
@thepassle
Copy link
Member

Thanks for looking into this though, appreciate it!

@Matsuuu
Copy link
Contributor Author

Matsuuu commented Jun 21, 2021

My pleasure! Let me know if there's something else I can help out with!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants