I'm pretty new to meteor so I'm just writing a simple app but really want to make it as TDD as possible (worth mentioning I'm also new to Mocha). So I've added the mike:mocha and velocity:core packages and written a super simple initial test just to see if I can get things to work, which I've added at tests/mocha/client/tests.js:
if (typeof MochaWeb != 'undefined') {
MochaWeb.testOnly(function () {
describe('Friends are added successfully', function () {
it('Should add a new person to the Friend collection', function(done) {
var friendId = Friends.insert(
{ firstName: 'New',
lastName: 'Friend'});
var friend = Friends.findOne({'firstName':'New'});
console.log(friend);
chai.assert.equal(friend.length === 1);
done();
});
});
})
;}
My problem is that when I run either the meteor command or meteor --test, I get nothing in the terminal apart from the expected:
=> Started proxy.
=> Started MongoDB.I20150115-22:31:03.216(0)? [velocity] chokadir watching /correctDirectory/tests
=> Started your app.
=> App running at: http://localhost:3000/
But then Velocity just hangs (a blue circle with a wider blue ring around it - no greens or red), pulsating and not providing any feedback whatsoever. None on the developer console or the terminal either! I tried checking localhost:5000 but this comes back as 'not available'.
Not sure how to start with figuring this one out!
Thanks in advance to anyone who can help :)
I was able to get your example to work on my local, so I would recommend checking versions of your software and get that in line first.
Here are a few things you can check, but I'll show what's on my machine for comparison:
Check your version of node
node -v
v0.10.35
If necessary, upgrade node. On my mac, I do the following:
brew update && brew upgrade node
If you don't have a mac, you might want to google for upgrade instructions for your machine's platform.
Check your package versions
meteor list
meteor-platform 1.2.1
mike:mocha 0.5.1
velocity:core 0.4.5
Check your meteor version
meteor --version
Meteor 1.0.2.1
If necessary, upgrade meteor and related packages
meteor update
If none of that helps, please post additional information. Additionally, you can also create an issue on Github for Velocity.
Related
I recently enabled App Check for my firebase app and enforced it on both my cloud functions and database. The cloud function workflow is behaving correctly. However, I can no longer access the database from the function. A minimal version of my callable function looks something like this:
exports.myFunc = functions.https.onCall(async (data, context) => {
const adminApp = admin.initializeApp();
const ref = adminApp.database().ref('some-node');
if (context.app === undefined) {
throw new functions.https.HttpsError(
'failed-precondition',
'The function must be called from an App Check verified app.',
);
}
try {
return (await ref.orderByKey().equalTo('foo').get()).exists()
} catch(exc) {
console.error(exc);
}
});
This used to work before App Check, but now it fails and I see this in the logs:
#firebase/database: FIREBASE WARNING: Invalid appcheck token (https://my-project-default-rtdb.firebaseio.com/)
Error: Error: Client is offline.
Seems like I need to do something extra to get the admin app to pass App Check verification down to the database, but I haven't been able to find any documentation on this yet. I also tried using the app instance from functions.app.admin instead of initializing a new one, but this didn't help.
I have the latest version of the packages:
"firebase-admin": "^9.10.0"
"firebase-functions": "^3.14.1"
firebaser here
The behavior you're seeing is not how it's supposed to work, and we've been able to reproduce it. Thanks for the clear report, and sorry you encountered this.
If you (re)install the Firebase Admin SDK today, you won't be experiencing this same problem as we've fixed the problem in the #firebase/database dependency (in this PR).
If you're (still) experiencing the problem, you can check if you have the correct #firebase/database dependency by running:
npm ls #firebase/database
results look something like this:
temp-admin#1.0.0 /Users/you/repos/temp-admin
└─┬ firebase-admin#9.11.0
└── #firebase/database#0.10.8
If your #firebase/database version is lower than 0.10.8, you'll have to reinstall the Admin SDK, for example by deleting your node_modules directory and your package-lock.json file and running npm install again. This may also update other dependencies.
So... this morning... I got an email saying:
Our records show that you own projects with App Engine applications or
Cloud Functions that are still calling the pre-GA v0.1 and v1beta1
endpoints of the App Engine and Cloud Functions metadata server.
We’re writing to let you know that these legacy endpoints are
scheduled to be turned down on April 30, 2020. After April 30, 2020,
requests to the v0.1 and v1beta1 endpoints will no longer be
supported, and may return HTTP 404 NOT FOUND responses.
I'm only using Firebase Functions to send messages... and the email went on to identify my sendMessage function as the culprit. But I can't... for the life of me... figure out WHERE I need to update the endpoints. My sendMessage function is as follows:
exports.sendMessage = functions.database.ref('/messages/{receiverUid}/{senderUid}/{msgId}')
.onWrite(async (change, context) => {
const message = change.after.val().body;
const receiverUid = change.after.val().receiverUid;
const senderUid = change.after.val().senderUid;
const msgId = change.after.val().msgId;
if (!change.after.val()) {
return console.log('Sender ', senderUid, 'receiver ', receiverUid, 'message ', message);
}
console.log('We have a new message: ', message, 'for: ', receiverUid);
I've tried following some of the Curl suggestions from this link: https://cloud.google.com/compute/docs/migrating-to-v1-metadata-server
...but every time I try one of them I get:
curl: (6) Couldn't resolve host 'metadata.google.internal'
So... at this point... I have no idea what it is I'm supposed to change or where I'm supposed to look. Any help would be appreciated.
I had this same problem, and didn't see any of the libraries I was using listed here.
In my case, the culprit turned out to be firebase-admin. I was using version 7.3.0, and I found this gem:
$ grep -rni "computeMetadata/" *
firebase-admin/lib/auth/credential.js:30:var GOOGLE_METADATA_SERVICE_PATH = '/computeMetadata/v1beta1/instance/service-accounts/default/token';
So, I updated my Cloud Functions libraries as shown here:
npm install firebase-functions#latest --save
npm install firebase-admin#latest --save-exact
and then, voila!
$ grep -rni "computeMetadata/" *
node_modules/firebase-admin/lib/auth/credential.js:30:var GOOGLE_METADATA_SERVICE_PATH = '/computeMetadata/v1/instance/service-accounts/default/token';
Then I redeployed and problem solved.
I searched at the https://github.com/firebase/firebase-functions repo latest version (3.3.0), and I found the file: spec/fixtures/https.ts. Inside this file there are some mock functions, which use the old: /computeMetadata/v1beta1 endpoint.
This might mean that firebase-functions modules package should be updated to use the /computeMetadata/v1 endpoint instead.
Fwiw I found this old dependency in package.json was dragging in other very old packages:
"#google-cloud/functions-emulator": "^1.0.0-beta.6",
In particular it brought in gcs-resumable-upload v 0.10.2, which is below the v 0.13.0 recommended by google (see https://cloud.google.com/compute/docs/migrating-to-v1-metadata-server#apps-to-update). Probably others too.
The fix was to either:
remove #google-cloud/functions-emulator, or
switch to its modern replacement, #google-cloud/functions-framework
I have trouble setting up a simple iron:router example: (docs, sample app)
meteor create testapp
cd testapp
home.html:
<template name="Home">
<h1>Welcome</h1>
home
</template>
router.js:
Router.route('/', function () {
this.render('Home'); // Also tried 'home'
});
Starting the server:
meteor
Then I get (client side):
Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it?
at null._render (http://localhost:3000/packages/iron_dynamic-template.js?32038885cb1dad7957291ffebfffcb7f8cd57d20:239:17)
at doRender (http://localhost:3000/packages/blaze.js?88aac5d3c26b7576ac55bb3afc5324f465757709:1853:25)
...
What am I doing wrong ?
Note: I get the exact same error if I clone the example application (basic.html and basic.js).
meteor list
autopublish 1.0.1 Publish the entire database to all clients
insecure 1.0.1 Allow all database writes by default
iron:router 0.9.4 Routing specifically designed for Meteor
meteor-platform 1.1.2 Include a standard set of Meteor packages in your app
Also:
meteor --version
Meteor 0.9.4 <- Why all standard packages and meteor platform are > 1.0 and this is 0.9.4 ?
Currently, there are two versions of iron:router.
iron:router#0.9.4 is the one added by default when you type meteor add iron:router, this version is the latest in the "legacy" branch of iron:router that came up more than one year ago, it's the one that everyone is probably still using, although they should definitely update to...
iron:router#1.0.0-preX with X = 4 as of 20/10/2014, which is a complete rewrite of the package intended to be backward compatible, but introducing a new, nicer and polished API. This version will likely be set as default when meteor hits 1.0.0 later this year. The problem is that github page of iron:router shows this particular branch (1.0.0-pre4) along with examples that people believe are usable with 0.9.4.
This means that you are most likely using the wrong version of iron router, remove it with meteor remove iron:router and meteor add iron:router#1.0.0-pre4 instead.
Recommended reading to learn about the latest iron:router syntax :
http://eventedmind.github.io/iron-router/
Sometimes the guide is not completely up-to-date with the pre-release version, if you want to keep up with the latest stuff take a look at github issues.
Meteor 0.8.0 is out with the new Blaze rendering, which is great... for the future.
At the present I can't run my Iron Router powered app: updated -> ran meteor -> white browser screen. I guess I'll roll back to 0.7.2. but that gives me a fuzzy feeling. Its like have a new computer with no internet connection. Is there any fix for these changes? At least for Iron Router?
Note Comment (although it was in the title):
I am learning meteor using the Discover Meteor book, it's a great book written by same author of Iron Router; I love it. However, if meteor changed that much am I wasting my time?
Update
#iAmME's solution works great! I solved it another way that also fixed iron-router-progress by modifying the smartpackage. Just wanted to post it if it helps anyone:
{
"packages": {
"blaze-layout": {},
"iron-router":
{
"git": "https://github.com/EventedMind/iron-router.git",
"branch": "blaze-integration"
},
"iron-router-progress":
{
"git": "https://github.com/Multiply/iron-router-progress.git",
"branch": "blaze-integration"
}
}
}
Just faced the same issue,
Did the following and works fine
It occurs mostly because of the iron-router package and few other packages which are using spark as dependency and first re-install the iron-router like below
meteor remove iron-router
rm -rf packages/iron-router
mrt update
mrt add iron-router
Just re-installing the iron-router will update you to the new version and also it installs blaze-Layout automatically with the iron-router(which is the new templating system).
After updating iron-router,Even now if you are getting spark is not defined error,check which package is using spark and update those packages too.
You have to update your iron-router package. Check out the Iron Router github page https://github.com/EventedMind/iron-router for information on what's new in their 0.7.0 release. It works for Meteor 0.8.0.
Can anyone tell me why the code below throws the following error? :
Error: A method named '/players/insert' is already defined
I'm new to Meteor and coffeescript so I may be overlooking something simple.
Here's my port of the leaderboard example to coffeescript:
###
Set up a collection to contain player information. On the server,
it is backed by a MongoDB collection named "players."
###
Players = new Meteor.Collection("players")
if Meteor.is_client
Template.leaderboard.players = ->
Players.find({}, {sort: {score: -1, name: 1}})
Template.leaderboard.selected_name = ->
player = Players.findOne(Session.get "selected_player")
player and player.name
Template.player.selected = -> if Session.equals("selected_player", this._id) then "selected" else ''
Template.leaderboard.events = {
'click input.inc': ->
Players.update(Session.get("selected_player"), {$inc: {score: 5}})
}
Template.player.events = {
'click': ->
Session.set("selected_player", this._id)
}
# On server startup, create some players if the database is empty.
if Meteor.is_server
Meteor.startup ->
if Players.find().count() is 0
names = [
"Ada Lovelace"
"Grace Hopper"
"Marie Curie"
"Carl Friedrich Gauss"
"Nikola Tesla"
"Claude Shannon"
]
Players.insert({name: name, score: Math.floor(Math.random()*10)*5}) for name in names
The full stack trace is as follows:
[[[[[ ~/dev/meteor/leaderboard ]]]]]
Running on: http://localhost:3000/
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: A method named '/players/insert' is already defined
at app/packages/livedata/livedata_server.js:744:15
at Function.<anonymous> (app/packages/underscore/underscore.js:84:24)
at [object Object].methods (app/packages/livedata/livedata_server.js:742:7)
at new <anonymous> (app/packages/mongo-livedata/collection.js:111:13)
at app/leaderboard.js:4:11
at /Users/alex/dev/meteor/leaderboard/.meteor/local/build/server/server.js:109:21
at Array.forEach (native)
at Function.<anonymous> (/Users/alex/dev/meteor/leaderboard/.meteor/local/build/server/underscore.js:76:11)
at /Users/alex/dev/meteor/leaderboard/.meteor/local/build/server/server.js:95:7
Exited with code: 1
I'm running Meteor version 0.4.0 (8f4045c1b9)
Thanks in advance for assistance!
You would also get this error, regardless of using coffeescript or plain javascript, if you duplicated your files. For example, copying your sources files to a subdirectory named Backup would produce this error, because Meteor merges files from subdirectories.
This appears to be a configuration issue with coffeelint (installed globally with npm).
I originally installed coffeelint to check that my coffeescript code was correct and had no errors.
I installed coffeelint as per the instructions with:
sudo npm install -g coffeelint
coffeelint worked fine when run stand-alone against .coffee files.
However, when running any Meteor project with coffeescript package added I got the above error.
On a whim, I thought the error might be due to conflict with my exisiting node install.
I decided to uninstall coffeelint first with:
sudo npm uninstall -g coffeelint
and then deleted the previously meteor-generated leaderboard.js file.
After re-starting meteor the coffeescript example above worked as expected without errors.
try moving (ie copying and deleting the original )
Players = new Meteor.Collection("players")
one time below if Meteor.is_client
and another time below if Meteor.is_server
I don't know exactly why, as I'm new to Meteor too, but that worked for me, I assume that the server side needs it's own reference,as well as the client,
although declaring outside the scope should do the same (maybe a bug, remember they're still at 0.5.0 preview , which makes me think you might wanna upgrade and try some new smart packages that are with the new version, it looks like you're using 0.4), but when the files in my server wouldn't recognize anything I defined the root directory of meteor (which pushes these files to both client and server), I defined the server's own reference, and I got the same error, and until I moved the 'public' declaration of the reference to give the server and the client each their own copy, nothing worked.
Hopefully that helps...