raycast / extensions

Everything you need to extend Raycast.
https://developers.raycast.com
MIT License
5.34k stars 3.04k forks source link

[Arc] Search Tabs fails with JSON parsing issue #9758

Closed pablo-CoCreator closed 8 months ago

pablo-CoCreator commented 10 months ago

Extension

https://raycast.com/the-browser-company/arc

Description

Error:

SyntaxError: Expected ',' or '}' after property value in JSON at position 8729
    at JSON.parse (<anonymous>)
    at Object.E5 [as current] (/Users/thepmini/.config/raycast/extensions/606e26d8-b3c5-4760-8001-dccce1b872c4/search-tabs.js:87:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Steps To Reproduce

  1. Try to use "Search Tabs" command of Arc Extension.
  2. Error message displayed.

Current Behaviour

No response

Expected Behaviour

No response

raycastbot commented 10 months ago

Thank you for opening this issue!

πŸ”” @thomaspaulmann @pomdtr @zach-fuller @ankitchouhan1020 @pernielsentikaer @danpalmer @danulqua @rgrunberg @tleo19 @loris @bdsqqq you might want to have a look.

πŸ’‘ Author and Contributors commands The author and contributors of `the-browser-company/arc` can trigger bot actions by commenting: - `@raycastbot close this issue` Closes the issue. - `@raycastbot rename this issue to "Awesome new title"` Renames the issue. - `@raycastbot reopen this issue` Reopen the issue.
megaroeny commented 9 months ago

Been difficult to use this feature usually. Sometimes it works, usually it doesn't. Following and thanks!

thomaslombart commented 8 months ago

This issue is now a bounty target πŸ’°

Hey there, we need help from our community to tackle this issue. Working on it and having it fixed will allow you to get a month of Raycast Pro or a mug.

If you want to work on it, please let us know by posting a comment here with a rough estimate of how much time it'll take you to fix it. There are no hard deadlines, but we would like the issues to be addressed in a timely manner as this could be interesting for other contributors. You'll then be assigned the issue.

I'll be the point of contact for that. If you need more information, you can send me a message in the Slack community, or in this issue. When creating your PR, please tag me either in the description or in a comment so that I can properly review it: @thomaslombart.

I'll get in touch with you to give you the bounty once the issue is fixed.

Here's our guide about contributing to extensions: Contribute to an extension

Looking forward to your contribution!

thomaslombart commented 8 months ago

Some pointers for this issue:

There's been a lot of issues opened on this extension that's related to JSON parsing. They seem to come in two forms:

Most of the issues are closed because they got stale but it's still happening ([5165](https://github.com/raycast/extensions/issues/5165), [5305](https://github.com/raycast/extensions/issues/5305), [6040](https://github.com/raycast/extensions/issues/6040), [7829](https://github.com/raycast/extensions/issues/7829), [8395](https://github.com/raycast/extensions/issues/8395), [8794](https://github.com/raycast/extensions/issues/8794), [9109](https://github.com/raycast/extensions/issues/9109), [9758](https://github.com/raycast/extensions/issues/9758), [9887](https://github.com/raycast/extensions/issues/9887)). The root cause is probably due to a wrong JSON data that is produced through an AppleScript code.

I've tested the following characters in an Arc tab and they all seem to work: . + * ? [ ^ ] $ ( ) { } = ! < > | : -

Only the backslash (\) isn't working and produces a Bad escaped character error. So, I'm not sure about all of the other errors.

Some potential solutions that could address this issue:

loris commented 8 months ago

Also not able to reproduce the issue except with the \ character. I have renamed a tab Η΄Θ‘Η»Ε£Δ―Ζˆ ^$.?*'|+A-Zaz09_!~() αΊ—Ε™ΘΕ§Ε§Δ―ΖžΙ‡ ε½“δ½ ηœ‹εˆ°θΏ™δΈͺζ—Ά and it properly load in the Raycast extension, so i'm not sure neither about the other errors

xilopaint commented 8 months ago

Hey @thomaslombart, I got it to work with \. Example foo \ bar:

Screenshot 2024-02-14 at 08 14 58

I'll submit a PR.

xilopaint commented 8 months ago

Just checking all the related issues in this moment to make sure my approach fixes all of them.

xilopaint commented 8 months ago

@thomaslombart Just submitted #10756 with the fix.

xilopaint commented 8 months ago

Been difficult to use this feature usually. Sometimes it works, usually it doesn't. Following and thanks!

@megaroeny My PR fixes the issue related to the use of \ in tab titles. If you encounter the issue with tabs that don't contain a backslash, please let me know.

megaroeny commented 8 months ago

Been difficult to use this feature usually. Sometimes it works, usually it doesn't. Following and thanks!

@megaroeny My PR fixes the issue related to the use of \ in tab titles. If you encounter the issue with tabs that don't contain a backslash, please let me know.

Sounds good! I typically don't notice tab titles with a backslash. The last time I tried today, it would still open to a blank black tab. πŸ€·πŸΌβ€β™‚οΈ

How do I know if I received this fix/latest version? Is there a way to see a version number in Raycast?

xilopaint commented 8 months ago

How do I know if I received this fix/latest version? Is there a way to see a version number in Raycast?

You can subscribe to notifications for #10756. The fix will be available once the PR is merged.

pernielsentikaer commented 8 months ago

How do I know if I received this fix/latest version? Is there a way to see a version number in Raycast?

It's now merged πŸ™‚

You can run the command Check For Extension Updates. Raycast also checks every fourth hour for new updates

megaroeny commented 8 months ago

It's now merged πŸ™‚

You can run the command Check For Extension Updates. Raycast also checks every fourth hour for new updates

Seems to work! Tried a few favorites across multiple Spaces, and it (eventually) goes to that tab! I'm sure the performance aspect is challenging, depending on how many tabs/favs/etc folks have. But it works! πŸ‘

Tip: I had to give it a bit of time to reindex the tabs, search, etc.

megaroeny commented 8 months ago

Okay, Arc just got an update, and the extension/command keeps failing now. And then it prompts me to reload it. 😒 I'll attempt reinstalling it to see if it helps, but try updating Arc and test again/monitor it. Sorry! 🀦🏼

It does work once or twice, but then breaks (on my end at least), since the Version 1.30.0 (46409) update.

xilopaint commented 8 months ago

Okay, Arc just got an update, and the extension/command keeps failing now. And then it prompts me to reload it. 😒 I'll attempt reinstalling it to see if it helps, but try updating Arc and test again/monitor it. Sorry! 🀦🏼

It does work once or twice, but then breaks (on my end at least), since the Version 1.30.0 (46409) update.

@megaroeny It is unlikely that the issue is related to the Arc version. The extension works fine for me on v1.30.0. The most likely scenario is that it is related to the URL or title of the tabs you have open. Could you determine which tab is causing the problem? To do this, you can try removing your open tabs one by one and running the Search Tabs command in Raycast each time.

megaroeny commented 8 months ago

It is unlikely that the issue is related to the Arc version. The extension works fine for me on v1.30.0. The most likely scenario is that it is related to the URL or title of the tabs you have open. Could you determine which tab is causing the problem? To do this, you can try removing your open tabs one by one and running the Search Tabs command in Raycast each time.

It seems to work now, yes. The last time I got the blank/black screen or the extension breaking, I believe it was a Twitch tab. But that doesn't have any \ in it.

When I use it again tomorrow (ended my work day) I can follow-up more clearly.

thomaslombart commented 8 months ago

Okay, Arc just got an update, and the extension/command keeps failing now

@megaroeny does it still fail with the same error? (SyntaxError: Expected ... after property value in JSON at position ...)

megaroeny commented 8 months ago

does it still fail with the same error? (SyntaxError: Expected ... after property value in JSON at position ...)

Where would I see that? I haven't worked since Friday. When the extension crashed, it was a Raycast specific design/error message. Just mentioning to reload it.

I'll follow up this week when it happens again.

megaroeny commented 8 months ago

@thomaslombart Today I'm getting a "Failed to fetch latest data" timeout error when using the "Search tabs" command. ☹️

image

Error: Command timed out after undefined milliseconds: osascript
Timed out
    at Timeout._onTimeout (/Users/reonytonneyck/.config/raycast/extensions/606e26d8-b3c5-4760-8001-dccce1b872c4/search-tabs.js:8:319917)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
xilopaint commented 8 months ago

@megaroeny This doesn't look like a parsing issue. I suggest that you open an issue with this content. Btw, do you have an old Mac and/or had an enormous amount of open tabs when the error was triggered? Do you see this error regardless of how many tabs you have open?

megaroeny commented 8 months ago

Btw, do you have an old Mac and/or had an enormous amount of open tabs when the error was triggered? Do you see this error regardless of how many tabs you have open?

Nope. M1 Macbook Pro (16GB), and probably only had a few tabs actually open/loaded. I do have a bunch of bookmarks I've imported from my previous browser, so I don't lose those. But those are all "closed" and in folders. Would that be an issue?

I can open a separate/related issue later as well. No worries.

xilopaint commented 8 months ago

xI do have a bunch of bookmarks I've imported from my previous browser, so I don't lose those. But those are all "closed" and in folders.

Actually, It doesn't make any difference if they are closed or not, the extension will parse them anyway. However, It would only be relevant if it is a huge number.

megaroeny commented 8 months ago

Actually, It doesn't make any difference if they are closed or not, the extension will parse them anyway. However, It would only be relevant if it is a huge number.

I just did a quick check and it's probably around 1700 items... πŸ™ˆ That probably explains it. Maybe I should just get rid of that space and not use Arc in that manner... I'll give it a try and follow-up in #10847

xilopaint commented 8 months ago

I just did a quick check and it's probably around 1700 items... πŸ™ˆ That probably explains it. Maybe I should just get rid of that space and not use Arc in that manner... I'll give it a try and follow-up in #10847

1700 items is a huge number and the likely cause of the error.

megaroeny commented 8 months ago

1700 items is a huge number and the likely cause of the error.

Just deleted that huge space, and confirmed it was! Works super snappy now! πŸ₯³

xilopaint commented 8 months ago

Just deleted that huge space, and confirmed it was! Works super snappy now! πŸ₯³

AppleScript will always struggle to process large databases. Your issue could probably be solved by using runAppleScript from @raycast/utils instead of the run-applescript package and increasing the timeout. However, I'm not sure if we should address this kind of issue for an unreasonable amount of items, as it would also result in a slow UX that may not be well understood by the user.

thomaslombart commented 8 months ago

@xilopaint Are we good on the parsing issue, or is it still ongoing work? πŸ™‚

xilopaint commented 8 months ago

@thomaslombart No ongoing work. If someone comes up with a new reproducible parsing issue we can fix it in a new PR. OP does not appear to be a regular GitHub user.

thomaslombart commented 8 months ago

Alright, then I'll mark the issue as solved since @megaroeny doesn't face it anymore, and the backslash issue has been fixed. Let's see if this pops up again.

megaroeny commented 8 months ago

If anyone wants to do what I was doing and finds this issue, I have a solution as well, mentioned here: https://github.com/raycast/extensions/issues/10847#issuecomment-1959532140

Thx for the work on this y'all. πŸ™πŸΌ