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

withTracker breaks with renderToNodeStream: SynchronousCursor requires a fiber #251

Closed
er-dev opened this issue Mar 13, 2018 · 5 comments
Closed

Comments

@er-dev
Copy link

er-dev commented Mar 13, 2018

I am trying to use React 16's new renderToNodeStream functionality. I see that support was added Meteor 1.6.1.

The react-meteor-data package's withTracker wrapper does not support renderToNodeStream because SynchronousCursor requires a Fiber in order to run DB queries like Things.find().fetch()

W20180313-14:42:53.055(-7)? (STDERR) Error: Can't wait without a fiber
W20180313-14:42:53.055(-7)? (STDERR)     at Function.wait (/Users/andrew/.meteor/packages/meteor-tool/.1.6.1.lyfx7l.cwu7h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:159:9)
W20180313-14:42:53.056(-7)? (STDERR)     at Future.wait (/Users/andrew/.meteor/packages/meteor-tool/.1.6.1.lyfx7l.cwu7h++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:448:10)
W20180313-14:42:53.056(-7)? (STDERR)     at SynchronousCursor._nextObject (packages/mongo/mongo_driver.js:1018:47)
W20180313-14:42:53.056(-7)? (STDERR)     at SynchronousCursor.forEach (packages/mongo/mongo_driver.js:1052:22)
W20180313-14:42:53.056(-7)? (STDERR)     at SynchronousCursor.map (packages/mongo/mongo_driver.js:1062:10)
W20180313-14:42:53.056(-7)? (STDERR)     at SynchronousCursor.fetch (packages/mongo/mongo_driver.js:1086:17)
W20180313-14:42:53.056(-7)? (STDERR)     at Cursor.(anonymous function) [as fetch] (packages/mongo/mongo_driver.js:876:44)
W20180313-14:42:53.056(-7)? (STDERR)     at ThingsContainer.jsx.module.exportDefault.withTracker (imports/containers/ThingsContainer.jsx:38:25)
W20180313-14:42:53.057(-7)? (STDERR)     at ReactMeteorDataComponent.getMeteorData (packages/react-meteor-data/ReactMeteorData.jsx:195:12)
W20180313-14:42:53.057(-7)? (STDERR)     at MeteorDataManager.calculateData (packages/react-meteor-data/ReactMeteorData.jsx:37:21)
W20180313-14:42:53.057(-7)? (STDERR)     at ReactMeteorDataComponent.componentWillMount (packages/react-meteor-data/ReactMeteorData.jsx:134:43)
W20180313-14:42:53.057(-7)? (STDERR)     at resolve (/Users/andrew/Development/react/meteor-ssr/node_modules/react-dom/cjs/react-dom-server.node.development.js:2119:12)
W20180313-14:42:53.057(-7)? (STDERR)     at ReactDOMServerRenderer.render (/Users/andrew/Development/react/meteor-ssr/node_modules/react-dom/cjs/react-dom-server.node.development.js:2260:22)
W20180313-14:42:53.057(-7)? (STDERR)     at ReactDOMServerRenderer.read (/Users/andrew/Development/react/meteor-ssr/node_modules/react-dom/cjs/react-dom-server.node.development.js:2234:19)
W20180313-14:42:53.058(-7)? (STDERR)     at ReactMarkupReadableStream._read (/Users/andrew/Development/react/meteor-ssr/node_modules/react-dom/cjs/react-dom-server.node.development.js:2541:38)
W20180313-14:42:53.058(-7)? (STDERR)     at ReactMarkupReadableStream.Readable.read (_stream_readable.js:442:10)
W20180313-14:42:53.058(-7)? (STDERR)     at nReadingNextTick (_stream_readable.js:797:8)
W20180313-14:42:53.058(-7)? (STDERR)     at _combinedTickCallback (internal/process/next_tick.js:135:11)
W20180313-14:42:53.058(-7)? (STDERR)     at process._tickDomainCallback (internal/process/next_tick.js:218:9)
@themao
Copy link

themao commented Mar 20, 2019

Any updates on this? I've been lucky to find this issue, banging my head around this error and trying to wrap it with Meteor.bindEnvironment somehow. So far I switched back to using renderToString.

@CaptainN
Copy link
Collaborator

CaptainN commented Jul 15, 2019

There is new work on a hooks based implementation of withTracker (built on top of useTracker) in #262. It has a very simple server implementation. I wonder if that should be wrapped with Meteor.bindEnvironment by default.

Maybe check that fork out in your local packages directory, add Meteor.bindEnvironment and see if it solves your issue?

function useTrackerServer(reactiveFn) {
  return Meteor.bindEnvironment(reactiveFn)();
}

@CaptainN
Copy link
Collaborator

Using Meteor.bindEnvironment didn't work here (though it did stop a weird refresh loop). I actually don't think this is a problem with react-meteor-data because in my package npdev:collections I bypassed useTracker completely, and it still gave me that same error when using renderToNodeStream. There is also this old flow-router issue, which talks about similar issues. I think this may be something in core.

@CaptainN
Copy link
Collaborator

Another interesting observation is that even though I get an error:

events.js:183
throw er; // Unhandled 'error' event
^

AssertionError [ERR_ASSERTION]: Cannot await without a Fiber

Everything works just fine.

@filipenevola
Copy link
Collaborator

I'm closing this just because it's too old. We can open new issues for items that are still valid.

Most of these items were solved already or replaced by new strategies (like hooks)

@meteor meteor locked and limited conversation to collaborators Jan 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants