-
Notifications
You must be signed in to change notification settings - Fork 9
Fix infinite ♾️ remix loop when BYPASS_AUTH set in editor-api #1007
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
floehopper
merged 1 commit into
main
from
fix-infinite-loop-when-remixing-project-with-bypass-auth-set-in-editor-api
May 13, 2024
Merged
Fix infinite ♾️ remix loop when BYPASS_AUTH set in editor-api #1007
floehopper
merged 1 commit into
main
from
fix-infinite-loop-when-remixing-project-with-bypass-auth-set-in-editor-api
May 13, 2024
Conversation
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
|
Previously when `BYPASS_AUTH` was set to `true` in `editor-api` and a remix was triggered in `editor-ui`, the editor went into an infinite loop creating remix after remix of the same project. This was happening, because `saveTriggered` was never being set to `false` in the "editor/remixProject/pending" case in `EditorSlice` like it is being in "editor/saveProject/pending". Thus this condition [1] in the `useProjectPersistence` hook was always `true` and `syncProject("remix")` was repeatedly dispatched. We were somehow (mostly?) getting away with this when `BYPASS_AUTH` was not set in `editor-ui`, because of the extra time taken to make real authentication requests from within the API request to create the remixed project. This meant that by the time the `useProjectPersistence` hook was executed for the 2nd time, `isOwner(user, project)` [2] returned `true` and so `syncProject("save")` was dispatched instead of `syncProject("remix")`. This in turn meant that the "editor/saveProject/pending" case was executed and thus `saveTriggered` was set to `false` preventing the infinite loop at the cost of an unintended/unnecessary save of the remixed project just created. By setting `saveTriggered` to `false` in the "editor/remixProject/pending" case like we do in the "editor/saveProject/pending" case, we can prevent the infinite loop and the extra saving of the project. [1]: https://github.com/RaspberryPiFoundation/editor-ui/blob/2df8a9761bff2de4824a7815252eb62560e85356/src/hooks/useProjectPersistence.js#L23 [2]: https://github.com/RaspberryPiFoundation/editor-ui/blob/2df8a9761bff2de4824a7815252eb62560e85356/src/hooks/useProjectPersistence.js#L24
1002a89
to
e1b9269
Compare
|
loiswells97
approved these changes
May 13, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for fixing this 👍
Merged
floehopper
added a commit
that referenced
this pull request
Jun 4, 2024
### Added - Add `project_name_editable` attribute to web component (#1009) - Fires custom event when the theme changes (#1015) - Add `output_only` attribute to web component (#1019 & originally #782) - Add `assets_identifier` attribute to web component (#1019 & originally #901) - Enhance `code` attribute on web component to override project main component content (#1019 & originally #901) - Add `runCode`, `stopCode` & `rerunCode` methods to web component (#1019 & originally #899) - Send error details in "editor-runCompleted" event (#1019 & originally #915) - Return error details to web component (#1019 & originally #915) - Add `output_panels` attribute to web component (#1019 & originally #909) ### Changed - Remove unused `/embedded/projects/:identifier` route (#1013) ### Fixed - Remove unused `REACT_APP_LOGIN_ENABLED` env var (#1006) - Fix infinite remix loop when `BYPASS_AUTH` set in `editor-api` (#1007) - Fixes for docker-compose.yml (#1008) - Fix deprecation warnings in GitHub Actions (#1011) - Removed unused `isEmbedded` param from `useProject` call in `EmbeddedViewer` (#1016) - Improvements to Cypress specs in CI (#1017) - Fix warnings and verbose output when starting Webpack Dev Server (#1018) - Add e2e spec for project remix behaviour in web component (#1020) - Fix initial value of `user` in `WebComponentLoader` (#1021) - Make `authKey` in e2e web component spec more realistic (#1022) - Remove unused `ComponentStore` (#1023)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously when
BYPASS_AUTH
was set totrue
ineditor-api
and a remix was triggered ineditor-ui
, the editor went into an ♾️ infinite loop creating remix after remix after remix of the same project...This was happening, because
saveTriggered
was never being set tofalse
in the "editor/remixProject/pending" case inEditorSlice
like it is being in "editor/saveProject/pending". Thus this condition in theuseProjectPersistence
hook was alwaystrue
andsyncProject("remix")
was repeatedly dispatched.editor-ui/src/redux/EditorSlice.js
Lines 372 to 375 in 2df8a97
editor-ui/src/redux/EditorSlice.js
Lines 397 to 399 in 2df8a97
We were somehow (mostly?) getting away with this when
BYPASS_AUTH
was not set ineditor-ui
, because of the extra time taken to make real authentication requests from within the API request to create the remixed project. This meant that by the time theuseProjectPersistence
hook was executed for the 2nd time,isOwner(user, project)
returnedtrue
and sosyncProject("save")
was dispatched instead ofsyncProject("remix")
. This in turn meant that the "editor/saveProject/pending" case was executed and thussaveTriggered
was set tofalse
preventing the infinite loop at the cost of an unintended/unnecessary save of the remixed project just created.By setting
saveTriggered
tofalse
in the "editor/remixProject/pending" case like we do in the "editor/saveProject/pending" case, we can prevent the infinite loop and the extra saving of the project.