-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(@aws-amplify/datastore): Add SSR support for DataStore #6726
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
feat(@aws-amplify/datastore): Add SSR support for DataStore #6726
Conversation
WebSockets aren't supported in Node and this can cause memory leaks and security issues with multi-tenant customer data being shared
sammartinez
left a comment
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.
Soft approval as I want weigh in from @manueliglesias and @elorzafe on this before we merge
elorzafe
left a comment
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.
Nice work @ericclemmons 🌮 🎉 🥇 !
sammartinez
left a comment
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.
Lets add the unit tests needed to resolve the unit test failure and Ill be happy to do a full approval
manueliglesias
left a comment
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.
Minor comment, LGTM! 🎉
9457972 to
34d9ce6
Compare
Codecov Report
@@ Coverage Diff @@
## main #6726 +/- ##
==========================================
- Coverage 73.15% 73.13% -0.02%
==========================================
Files 211 211
Lines 13056 13065 +9
Branches 2542 2450 -92
==========================================
+ Hits 9551 9555 +4
- Misses 3312 3346 +34
+ Partials 193 164 -29
Continue to review full report at Codecov.
|
sammartinez
left a comment
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.
LGTM 🌮
9ed3af3 to
92599ee
Compare
|
I see this change now prevents subscriptions from being established in a Node environment, and I understand the justification above regarding multi-tenant apps sharing sockets. In our implementation, however, we are using the PubSub module in a client application running in a desktop environment and built with Electron. This pull request breaks the functionality of the application entirely, and we can not use the latest update. Is there a recommendation for this scenario? Could we introduce a mode that allows subscriptions to be made when explicitly set? |
|
@adamup928 Oh no! Can you open a new issue as a feature request? You're absolutely right: the restriction in Node does not apply to Electron apps, so we can do better detection to unblock you. Let's discuss more in that issue, but here are 2 solutions I'm aware of:
|
|
Thanks, @ericclemmons. Done! Here it is: #6873 |
|
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Issue #, if available: Based on #6146, this solves the security concerns with DataStore &
PubSub.subscribein Node environments.PubSub.subscribethrows in Node. This behavior wasn't explicitly supported and shouldn't be for security reasons. (Multi-tenant apps may share sensitive information across a single, accessible socket)DataStoredoesn't start the sync engine in Node.withSSRContextincludesDataStoreas a default module (along withAPIandAuth).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.