Skip to content

Conversation

bhunjadi
Copy link
Contributor

@bhunjadi bhunjadi commented Feb 19, 2024

I started working on Meteor 3.0 and managed to make some progress on the server-side. I started with links and also started adding types and use them in JS files which might help with this migration.

I managed to get the 4 tests in linker.tests.js working and will update progress here as I continue the work.

I'm replacing all calls to their *Async equivalents so I had to bump the minimal Meteor version to 2.8.1.

Tests todos:

  • Links
  • Exposures
  • Queries
  • Named queries
  • Reactive counts
  • GraphQL
  • Client tests

3rd party deps:

Other:

  • Update types
  • Setup lint
  • API changes docs

Compatibility with Meteor v2

  • getLink, add, set, etc functions in links should get Async suffix, client should stay the same

How to test

# v3
meteor create --release 3.0-beta.0 --bare test
cd test 
meteor npm i --save selenium-webdriver@3.6.0 chromedriver@2.36.0 simpl-schema@1.13.1 chai

# then we also need to add packages that are not published yet
mkdir packages
cd packages

# mongo-collection-instances
git clone -b migration/3.0 https://github.com/Meteor-Community-Packages/mongo-collection-instances.git

# meteortesting:mocha
git clone -b migrate/3.0 https://github.com/Meteor-Community-Packages/meteor-mocha.git meteor-mocha-repo
# copy package into packages
cp -R ./meteor-mocha-repo/package ./meteor-mocha

Package.json in test (see scripts for convenience methods)

{
  "name": "test",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "test": "MONGO_URL= METEOR_PACKAGE_DIRS=\"../:packages\" TEST_BROWSER_DRIVER=chrome meteor test-packages --driver-package meteortesting:mocha --once  --port 3010 ../",
    "test:server": "TEST_CLIENT=0 MONGO_URL= METEOR_PACKAGE_DIRS=\"../:packages\" TEST_BROWSER_DRIVER=chrome meteor test-packages --driver-package meteortesting:mocha --once  --port 3010 ../",
    "test:server:watch": "TEST_CLIENT=0 MONGO_URL= METEOR_PACKAGE_DIRS=\"../:packages\" TEST_BROWSER_DRIVER=chrome meteor test-packages --driver-package meteortesting:mocha  --port 3010 ../"
  },
  "dependencies": {
    "@babel/runtime": "^7.23.5",
    "chai": "^5.1.0",
    "chromedriver": "^2.36.0",
    "meteor-node-stubs": "^1.2.7",
    "selenium-webdriver": "^3.6.0",
    "simpl-schema": "^1.13.1"
  }
}

@StorytellerCZ
Copy link
Collaborator

This is most likely going to be a major version update, so minimum version of Meteor 2.8.1 is fine.

@StorytellerCZ StorytellerCZ linked an issue Feb 20, 2024 that may be closed by this pull request
@StorytellerCZ
Copy link
Collaborator

I'm going to release v1.5 in the coming days, most likely (pester me if I don't). After that the only releases I will do on the 1.x branch will be dependencies updates.

@StorytellerCZ StorytellerCZ added this to the V2.0 milestone Feb 28, 2024
@StorytellerCZ
Copy link
Collaborator

@harryadel it will be once we make the rounds. denormalize 0.7 will be released soon.

@StorytellerCZ StorytellerCZ modified the milestone: V2.0 Apr 1, 2025
publish-composite and denormalize updated to their latest versions.
@StorytellerCZ
Copy link
Collaborator

Updated dependencies for denormalize and publish-composite.

@StorytellerCZ
Copy link
Collaborator

If the tests pass I will release another beta. I think we could probably move to rc at this point. Thoughts? @bhunjadi @harryadel

@harryadel
Copy link

@StorytellerCZ Thank you for continuously pushing this. Yes, a new beta would be nice for sure.

@bhunjadi
Copy link
Contributor Author

bhunjadi commented Apr 1, 2025

@StorytellerCZ Yes, let's go with RC. @harryadel reported that beta is working ok

@StorytellerCZ
Copy link
Collaborator

Published cultofcoders:grapher@2.0.0-rc.0.
Updated versionsFrom to also include Meteor 3.1.2 and 3.2.
Minor update to dev dependencies.
Started CHANGELOG for v2 <= we need to make a migration guide @bhunjadi @harryadel

Copy link

@harryadel harryadel left a comment

Choose a reason for hiding this comment

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

I've read the migration. Can't believe the amount of work that went into it. Truly inspirational. Thank you @bhunjadi for this amazing gift. I've forked this endeavor and tried to make some changes, I'll ping you guys once I'm done.

@boomfly
Copy link

boomfly commented May 9, 2025

async code not work in reduce func.

Users.addReducers({
  roles: {
    body: {
      _id: 1,
    }
    reduce: async (object) => {
      result = await Roles.getRolesForUserAsync(object._id)
      console.log('roles reducer', result)
      return result
    }
  },
})

This query:

Users.createQuery({
    $filters: query,
    $options: options,
    roles: 1
})

return in roles = {}

@boomfly
Copy link

boomfly commented May 9, 2025

Add PR for async reducers bhunjadi#3

@harryadel
Copy link

bhunjadi#4

@bhunjadi
Copy link
Contributor Author

bhunjadi commented Jun 5, 2025

Add PR for async reducers bhunjadi#3

I pushed an update for async reducers. I went with Option B outlined in this comment, bhunjadi#3 (comment).
This means that client-side reactive query's fetch() function remains synchronous.

Breaking change is that query.fetch() no longer accepts options. This is actually related to supporting body.$options.skip. I guess workarounds must be possible.

cc @harryadel

@harryadel
Copy link

This is amazing work, thank you @bhunjadi 🙏

@StorytellerCZ
Copy link
Collaborator

Good, please make sure that the breaking change is documented.

@harryadel
Copy link

Please review and merge
bhunjadi#5

@bhunjadi
Copy link
Contributor Author

After doing some additional testing, async reducers are tougher to crack than I thought (see #484 (comment))

In the end we will need to have a breaking change and fetching in subscription will have to be done with the new method query.fetchReactiveAsync().

The backwards compatible sync fetch() with cache workaround was not working as desired. The thing is that

Tracker.autorun(() => {
    if (handle.ready()) {
         const res  = query.fetch(); // <--- fetching from cache
         
    }
});

Works when subscription just becomes ready, but it doesn't work on subsequent changes because Tracker.autorun callback is not triggered. Why? Because query.fetch() only uses cache and not collection.find().fetch() which would register that collection as dependency.
So, it looks like this has to be a breaking change.

Correct Tracker call is:

Tracker.autorun(async() => {
    if (handle.ready()) {
         const res  = await query.fetchReactiveAsync(); // <--- fetching from cache
         
    }
});

I checked my codebase which is pretty large and it appears this won't cause lot of changes because I have a React hook wrapper around reactive queries.

cc @harryadel @StorytellerCZ

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

Successfully merging this pull request may close these issues.

Grapher 2.0 to support Meteor 3.0

8 participants