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

feat: When closing over values in server$ the values should be marked as readonly #5238

Merged
merged 4 commits into from
May 10, 2024

Conversation

gitstart
Copy link
Contributor

What does this PR do?

This PR ensures that values serialized by server$() are immutable and triggers a clear error message if any mutation is attempted

Issue reference

#5019

Demo video/scrennshot:

https://www.loom.com/share/abc8b587001d4845bc55748000b0412f?sid=945d461e-79cc-4cd3-a80f-0e99bb0aa065
Happy hacking! 🎉


This code was written and reviewed by GitStart Community. Growing great engineers, one PR at a time.

…should be marked as readonly

Co-authored-by: wajihaNiazi <waijehaniazi204@gmail.com>
Co-authored-by: Phu Nguyen <51897872+phunguyenmurcul@users.noreply.github.com>
@netlify
Copy link

netlify bot commented Sep 28, 2023

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 6379002

@gioboa gioboa added COMP: qwik-city STATUS-2: PR waiting for review This PR is waiting for review and approval before merge labels Sep 29, 2023
@mhevery
Copy link
Contributor

mhevery commented Oct 4, 2023

Love this change. Let me know when it is ready.

Copy link
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add an e2e spec that tries to change an object on the server? Something like

server$(() => {
  try {
    myObject.deeper.foo = 'test'
    return false
  } catch (e) {
    if (/* some test that checks it errored because of freeze */)
      return true
    return false
  }
})

packages/qwik-city/runtime/src/server-functions.ts Outdated Show resolved Hide resolved
packages/qwik-city/runtime/src/server-functions.ts Outdated Show resolved Hide resolved
packages/qwik-city/runtime/src/server-functions.ts Outdated Show resolved Hide resolved
@gioboa
Copy link
Member

gioboa commented Oct 11, 2023

Hi @gitstart thanks for your help, are you still on this PR or is it abandoned?

@gitstart
Copy link
Contributor Author

Hi @gitstart thanks for your help, are you still on this PR or is it abandoned?

Sorry for the delay. we are still working on the issue

…should be marked as readonly

Co-authored-by: Hameed Abdulrahaman <hameedabdulrahamann@gmail.com>
Co-authored-by: wajihaNiazi <waijehaniazi204@gmail.com>
Co-authored-by: Phu Nguyen <51897872+phunguyenmurcul@users.noreply.github.com>
@wmertens
Copy link
Member

@gitstart could you rebase?

@wmertens
Copy link
Member

wmertens commented Mar 4, 2024

@gitstart still interested in finishing this?

@PatrickJS PatrickJS changed the title QWIKOSS-2 - [✨] When closing over values in server$ the values should be marked as readonly feat: When closing over values in server$ the values should be marked as readonly May 10, 2024
@PatrickJS PatrickJS marked this pull request as ready for review May 10, 2024 22:33
@PatrickJS
Copy link
Member

@wmertens @mhevery I'm changing this to only freeze in dev

@PatrickJS
Copy link
Member

in the future technically we can pass the current client value to the server then update the client signals from the server response

@PatrickJS PatrickJS merged commit b8bdc31 into QwikDev:main May 10, 2024
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP: qwik-city STATUS-2: PR waiting for review This PR is waiting for review and approval before merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants