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

can't identify subscriptions for v5 #13

Open
welkinwong opened this issue Sep 30, 2024 · 12 comments
Open

can't identify subscriptions for v5 #13

welkinwong opened this issue Sep 30, 2024 · 12 comments

Comments

@welkinwong
Copy link

Describe the bug
when just use Meteor.subscribe, FastRender not inject data

To Reproduce
Steps to reproduce the behavior:

  1. Go to meteor-fast-render/testApp/server/main.js
  2. remove line 39 .route function
  FastRender.route('/', async function () {
    await this.subscribe('links');
  });
  1. run meteor
  2. nothing injected
HMR: connected
App.jsx:8 {collectionData: {…}, subscriptions: {…}}collectionData: {}subscriptions: {}[[Prototype]]: Object
App.jsx:9 []
fast_render.js:31 FR: new subscription: links
fast_render.js:31 FR: new subscription: undefined
fast_render.js:31 FR: new subscription: meteor.loginServiceConfiguration
fast_render.js:31 FR: new subscription: meteor_autoupdate_clientVersions
fast_render.js:31 FR: new subscription: links
fast_render.js:31 FR: fast rendering completed!

Expected behavior
only Meteor.subscribe('links') maby work

Screenshots
Snipaste_2024-09-30_09-23-04

Desktop (please complete the following information):

  • OS: Mac
  • Browser: Chrome
  • Version: 129.0.6668.60
Copy link

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee your issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.

Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know

@copleykj
Copy link
Member

only Meteor.subscribe('links') maby work

@welkinwong That is actually an artifact that I should have removed and shouldn't be there. Meteor.subscribe would need to be called during server rendering to work for sending data to the client in this manner. Currently I have not dove into server rendering as I think it's going to take some mental gymnastics to wrap my head around how waiting on Meteor.subscribe to finish will work, when you can't actually await a call to Meteor.subscribe.

@copleykj
Copy link
Member

@welkinwong are you using server rendering in your projects where you will need Meteor.subscribe to work in this manner?

@welkinwong
Copy link
Author

@welkinwong are you using server rendering in your projects where you will need Meteor.subscribe to work in this manner?

my project look like:

routes.ts

export const Routes = [
   ...
  { path: '/path', Component: Page },
   ...
]

Page.ts

 import { useTracker } from 'meteor/react-meteor-data/suspense
// here is use suspense, because meteor3.0 need use fetchAsync on server

export const Page = () => {
  const docs = useTracker('docsList', () => {
    Meteor.subscribe('docs');
    return DocsCollection.find({}).fetchAsync();
  });

  return (
    <div>
      {docs.map(doc =>
        <ListItem key={doc.id} doc={doc} />
      )}
    </div>
  );
}

when access domain.com/path, the page will ssr output

@copleykj
Copy link
Member

So you are using SSR then? Are you using a package or is it a custom implementation?

@welkinwong
Copy link
Author

So you are using SSR then? Are you using a package or is it a custom implementation?

yes i using SSR, only meteor-fast-render package and react-meteor-data package, no more any else

@copleykj
Copy link
Member

copleykj commented Oct 4, 2024

@welkinwong are you using a custom SSR implementation?

@welkinwong
Copy link
Author

@welkinwong are you using a custom SSR implementation?

yes, actually I follow this package communitypackages:react-router-ssr

@copleykj
Copy link
Member

copleykj commented Oct 5, 2024

Got it. I should start work on that package along side getting Meteor.subscribe to work

@dnish
Copy link
Contributor

dnish commented Dec 2, 2024

@copleykj I just wanted to ask if v5 is already working for the standard cases (like Meteor.userId())? I've added the package, but Meteor.userId() is always undefined on the first render. If I call it via console, I get my current userId. This is what fast-render injects:

<script type="text/inject-data">%7B%22fast-render-data%22%3A%7B%22collectionData%22%3A%7B%7D%2C%22subscriptions%22%3A%7B%7D%2C%22loginToken%22%3A%22lKVhXYeoHQGTZ9GmmzJh3BFryR3Mc4ybflekLamPAMk%22%7D%2C%22fast-render-extra-data%22%3A%7B%7D%7D</script>

@dnish
Copy link
Contributor

dnish commented Dec 5, 2024

Got it. I should start work on that package along side getting Meteor.subscribe to work

Just added a pull request. There was a missing await before publishContext._runHandler(), now it works.

@copleykj
Copy link
Member

@dnish published v5.0.0-beta.1 with your changes and a couple other little fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants