I am using the aws-sdk
in the meteor-app and that is working without any problems.
When I start the new test-mode from Meteor 1.3.2.2 I get an Error directly.
I am basically only initializing the s3 object and that already breaks it.
import { AWS } from 'aws-sdk';
let s3 = new AWS.S3({
signatureVersion: 'v4'
});
Seeing the following Error:
/Users/manuelschoebel/.meteor/packages/meteor-tool/.1.3.2_2.1rvzhiz++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
throw(ex);
^
TypeError: Cannot read property 'Stream' of undefined
at Object.<anonymous> (.../meteorTestModeIssueWithAWSSdk/node_modules/aws-sdk/lib/http/node.js:2:44)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (.../meteorTestModeIssueWithAWSSdk/node_modules/aws-sdk/lib/aws.js:11:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
To recreate the issue see following repo:
Does anyone have an idea? Are there some modules somehow disabled while in testing mode or s.th.?
2 Likes
I figured that in development mode process.browser
is undefined
in the server scope. However in test-mode process.browser
is true
even though I am in the server scope e.g. Meteor.isServer
is true
.
I have the exact same issue. I’m using CollectionFS with the S3 adapter. The app runs perfectly in normal mode but in test mode, with or without --full-app
the app will not boot and I get the following error:
TypeError: Cannot read property 'Stream' of undefined
at Object.<anonymous> (/Users/tim/.meteor/packages/cfs_s3/.0.1.3.1wrcab9++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/http/node.js:2:44)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/tim/.meteor/packages/cfs_s3/.0.1.3.1wrcab9++os+web.browser+web.cordova/npm/node_modules/aws-sdk/lib/aws.js:11:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.Npm.require (/private/var/folders/_t/mf0yc4h973vd1_z0nr6r49840000gn/T/meteor-test-runvn4krt/.meteor/local/build/programs/server/boot.js:182:18)
at Writable (packages/cfs_s3/packages/cfs_s3.js:10:1)
I figured that there is a process.browser = true
somewhere very deep within a dependency of /usr/USER_NAME/.meteor/packages/babel-runtime
package of the global meteor installation. Two files are doing it acorn_csp.js
and acorn.js
.
I guess somehow meteor test
starts the application in a way that makes the library think it is in client-mode or something… It is a bit strange but should be investigated since I guess it will break every lib that checks on process.browser.
Unfortunately I did not yet come up with a workaround since you cannot simply process.browser = false
before you require the lib
I’m having the same issue as well. Am using aws-sdk
and getting TypeError: Cannot read property 'Stream' of undefined
when running meteor in test mode. Normally my app runs with no problems. My meteor version is 1.3.2.4
.
Bumping this. Having the same issue as well on aws-sdk. Only when running test this happens. If anyone has any ideas, please paste here. I have not been able to find a work around for this as of yet
I’m also seeing this. As a workaround, i’m doing this:
let AWSSDK;
if (!(Meteor.isAppTest || Meteor.isTest)) {
AWSSDK = require("aws-sdk");
}
else {
console.warn("Not loading aws-sdk; it's incompatible with test mode.");
/* could also do AWSSDK = { ... some test stub ... }; */
}
Has anyone found a solution to this? In Meteor 1.2, I wrote a local-only package for an AWS client, with unit tests. According to the instructions for migrating to 1.3, I moved the package to import
, but still want to unit test it server-side. It appears that for some reason Meteor treads the AWS module as available client-side and I have not been able to figure out how to prevent that.
So as you probably saw, the AWS module uses its own custom require
implementation that checks the value of process.browser
. The work-around I came up with after I posted my question below is
process.browser = false
const AWS = Npm.require('aws-sdk')
process.browser = testHack```
Tracked it down so far to http://j.mp/1TFpEDn setting process.browser = true
, but since this is a generated file and that line is nowhere in the source, I presume it’s put in there by the build.