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

Migrate for Meteor 3.0 #306

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open

Migrate for Meteor 3.0 #306

wants to merge 62 commits into from

Conversation

jankapunkt
Copy link
Member

@jankapunkt jankapunkt commented Jan 4, 2024

Continuing from #309

package.js Outdated Show resolved Hide resolved
@StorytellerCZ StorytellerCZ mentioned this pull request May 26, 2024
@jankapunkt
Copy link
Member Author

Once CI runs we should release a beta asap, wdyt @StorytellerCZ

@StorytellerCZ
Copy link
Member

Merged in from #309 as I couldn't push to the original branch for some reason.
There are several breaking changes.

@StorytellerCZ
Copy link
Member

@bhunjadi I will be watching your fork if anything comes up. I will release a beta shortly, but given that the tests and lint fail we have to look into that @jankapunkt

@StorytellerCZ
Copy link
Member

@jankapunkt 2.14 tests are failing. Not a bit issue, but it would be good to have a backward compatibility or figure out why. For myself it is not a release blocker as 3.0 tests pass. So the only real thing that we need to figure out is the MontiAPM issue that @harryadel and @brianlukoff spoke of.

@Sergeant61
Copy link

Hello, what is the latest situation, when I try this version 2.16, callbacks are not triggered.

my code:

if (Meteor.isServer) {
  Messages.before.insert(async function (userId, doc) {
    doc.search = doc.search || {}

    if (doc.userId) {
      const user = await Meteor.users.findOneAsync({ _id: doc.userId }, { fields: UserSearchFieldSelector })
      doc.search.user = user
    }

    if (doc.lastAgentUserId) {
      const lastAgentUser = await Meteor.users.findOneAsync({ _id: doc.lastAgentUserId }, { fields: UserSearchFieldSelector })
      doc.search.lastAgentUser = lastAgentUser
    }

    return true
  })
}

@StorytellerCZ
Copy link
Member

The tests are failing due to error in the email package which has nothing to do with this project. We might need to wait for Meteor 3.0.3 release before we are able to run tests properly.

@matheusccastroo
Copy link

For anyone also facing the montiapm related issue: the problem is that this package is trying to monkey patch the find method to support the hooks, and when doing that, it re-creates the mongo cursor and as such the montiapm:agent can't add it's metrics stuff (because it ends up without the synchronousCursor property).

I just released a version for this package (collection-hooks) without the find hooks, so if you don't use it, it will work for you: https://atmospherejs.com/quave/collection-hooks.

@jankapunkt
Copy link
Member Author

Thank you @matheusccastroo for the hotfix

I think under this circumstance we should make it globally configurable which methods to hook by default. @StorytellerCZ wdyt?

@StorytellerCZ
Copy link
Member

I don't know. The issue is with the insert hook which configuration would not really resolve. I'm fine with optimization of hooking only collections which actually have hooks assigned.

@zodern
Copy link

zodern commented Sep 8, 2024

The issue with montiapm:agent is more an issue with MeteorX - it's unable to get the synchronous cursor since the cursor it has access to is different than the one the fetch is run on when using collection hooks:

https://github.com/monti-apm/meteorx/blob/bd14ff6df893d18854367a1689e0c0e20e7b8b81/src/mongo-livedata.js#L64-L70

const newCursor = _super.call(this, abort ? undefined : selector, options)
const result = await newCursor[method](...args)
for (const aspect of aspects.after) {
await aspect.aspect.call(this, userId, selector, options, cursor)
}

I'm not familiar with this package, but a couple ideas are:

  • it seems a new cursor is created since the hooks could change the cursor options. Maybe it could re-use the original cursor if the options are not changed
  • it could add the new cursor as a property to the original cursor, so it can be accessed by outside code.
  • edit: the suggestion by @StorytellerCZ to not hook every collection would probably also fix this since MeteorX creates its own collection

@harryadel
Copy link
Member

Guys, I released a new version matb33:collection-hooks@2.0.0-rc.4. Please give it a test run. I tried it in my local application but something is not quite right so I'm still looking into it.

@StorytellerCZ
Copy link
Member

So pretty sure now that the latest rc caused my website to fall into infinite loading. Not sure why, but reverting to rc.4 fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Help with this issue is very much appreciated and sough out.
Projects
None yet
10 participants