-
Notifications
You must be signed in to change notification settings - Fork 75
Migrate comment mutations #3121
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ff9704c
Migrate comment mutations
feruzm 9170775
fix issues
feruzm 6be1c69
bump version and fix
feruzm b77e011
fix draft delete
feruzm 69d3552
diff patch
feruzm 727dd31
fixes patch and reports
feruzm c0d4593
fix patches
feruzm 984c2c7
update query keys
feruzm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| diff --git a/node_modules/hive-auth-wrapper/has-wrapper.js b/node_modules/hive-auth-wrapper/has-wrapper.js | ||
| index ff0b878778..7c7906f4d6 100644 | ||
| --- a/node_modules/hive-auth-wrapper/has-wrapper.js | ||
| +++ b/node_modules/hive-auth-wrapper/has-wrapper.js | ||
| @@ -40,6 +40,7 @@ let HAS_timeout = 60*1000 // default request expiration timeout (60 seconds) | ||
|
|
||
| let messages = [] | ||
| let wsHAS = undefined | ||
| +let wsHAS_creating = false // Guard against concurrent WebSocket creation | ||
| let trace = false | ||
|
|
||
| function getMessage(type, uuid=undefined) { | ||
| @@ -56,9 +57,25 @@ function getMessage(type, uuid=undefined) { | ||
|
|
||
| // HAS client | ||
| function startWebsocket() { | ||
| - wsHAS = new WebSocket(HAS_options.host) | ||
| + // Guard against concurrent WebSocket creation (e.g., rapid checkConnection calls | ||
| + // when app returns from background after Keychain interaction) | ||
| + if(wsHAS_creating) { | ||
| + if(trace) console.log("WebSocket creation already in progress, skipping") | ||
| + return | ||
| + } | ||
| + wsHAS_creating = true | ||
| + let ws | ||
| + try { | ||
| + ws = new WebSocket(HAS_options.host) | ||
| + } catch (error) { | ||
| + wsHAS_creating = false | ||
| + if(trace) console.log("WebSocket creation failed", error) | ||
| + return | ||
| + } | ||
| + wsHAS = ws | ||
| wsHAS.onopen = function() { | ||
| // Web Socket is connected | ||
| + wsHAS_creating = false | ||
| HAS_connected = true | ||
| if(trace) console.log("WebSocket connected") | ||
| } | ||
| @@ -95,9 +112,14 @@ function startWebsocket() { | ||
| } | ||
| } | ||
| wsHAS.onclose = function(event) { | ||
| - // connection closed, discard old websocket | ||
| - wsHAS = undefined | ||
| - HAS_connected = false | ||
| + wsHAS_creating = false | ||
| + // Only clear global reference if THIS WebSocket is still the current one. | ||
| + // Prevents a stale onclose from overwriting a newer WebSocket reference | ||
| + // (e.g., when app returns from background and a new connection was already created). | ||
| + if(wsHAS === ws) { | ||
| + wsHAS = undefined | ||
| + HAS_connected = false | ||
| + } | ||
| if(trace) console.log("WebSocket disconnected", event) | ||
| } | ||
| } | ||
| @@ -143,19 +165,23 @@ async function attach(uuid) { | ||
| } | ||
|
|
||
| async function checkConnection(uuid=undefined) { | ||
| - if ("WebSocket" in window) { | ||
| - // The browser support Websocket | ||
| + if (typeof WebSocket !== "undefined") { | ||
| if(HAS_connected) { | ||
| return true | ||
| } | ||
| - if(!wsHAS) { | ||
| + if(!wsHAS && !wsHAS_creating) { | ||
| startWebsocket() | ||
| } | ||
| if(!HAS_connected) { | ||
| // connection not completed yet, wait till ready | ||
| + // Added null safety: after await sleep(), wsHAS could be undefined | ||
| + // if onclose fired during the sleep. Also limit iterations to | ||
| + // prevent infinite loops when WebSocket fails to connect. | ||
| + let maxWait = Math.ceil(HAS_timeout / Math.max(1, DELAY_CHECK_WEBSOCKET)) | ||
| do { | ||
| await sleep(DELAY_CHECK_WEBSOCKET) | ||
| - } while(wsHAS && wsHAS.readyState==0) // 0 = Connecting | ||
| + maxWait-- | ||
| + } while(wsHAS && wsHAS.readyState === 0 && maxWait > 0) | ||
| } | ||
| if(HAS_connected && uuid) { | ||
| // WebSocket reconnected, try to attach pending request if any | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.