node.js

Firebase cloud function http request crashing

╄→尐↘猪︶ㄣ 提交于 2021-02-11 12:14:06
问题 I'm trying to send expo push notification via firebase cloud functions, in order to send notifications from the web app to devices that have downloaded the mobile app. When I send the request from Postman, it works just fine... i get the ok response and the notification shows up on my phone. But when I try to make the request from the web app, i get this in the functions log: Function execution took 22 ms, finished with status: 'crash' Any ideas why is this happening? Couldn't find anything

Can a setImmediate() function scheduled in an I/O callback recalculate timeout for other I/O notifications?

萝らか妹 提交于 2021-02-11 12:12:43
问题 There is the poll stage of the Node js's event loop. Its aim is to blockingly wait for I/O notifications and then execute needed callbacks. A timeout time of the waiting is calculated before entering this stage. If there were operations scheduled through setImmediate than the timeout is set at 0, if timers took place than timeout is set with a view of them and if there are no such impediments the blocking would continue "forever". What will happen if the timeout is initially set at "infinity"

Sails Js File uploads. file uploaded successfully but text params are missing while

五迷三道 提交于 2021-02-11 12:10:49
问题 I am using sails js. I am trying to upload an array of files and create record for each file in mongodb. In db, I will be storing filename. i am uploading PDF files here. But as the size increases to 1 MB, The file is geeting uploaded but the text fields from the HTML end are missing. If the files size is reduced, then everything is going smooth. Where am I going wrong? Can someone help me. var f= req.file('ifile') f.upload({dirname:'../../assets/images/logs'}, function whenDone(err, files) {

Socket.io my middleware for custom Id does not works

爱⌒轻易说出口 提交于 2021-02-11 12:10:05
问题 i followed instructions in this link Rohit Nishad and my data is well passed from client to server. But the ID is not passed from my middleware with the overwritten function. A new Generated ID is shown on socket.io connection. Any idea what's going wrong please ? I'm using socket.io v3.1.0 server.js const express = require('express'); const app = express(); const http = require('http'); const server = http.createServer(app); const socketIO = require('socket.io'); const io = socketIO(server,

Firebase - Failing to install firebase using npm but yarn works

Deadly 提交于 2021-02-11 12:06:40
问题 λ npm -g install firebase npm ERR! Unexpected end of JSON input while parsing near '...9gwBD9c+ThTWWmNBXcfJZ' npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\2nchy\AppData\Roaming\npm-cache\_logs\2020-07-13T18_19_46_173Z-debug.log I increased timeout seconds in .npmrc to 12,000 and downgraded npm to 6.3.17 , cleared the cache as it was suggested and even installed it from an empty directory but still getting an almost same error UPDATE Uninstalled nodejs and

Firebase - Failing to install firebase using npm but yarn works

梦想与她 提交于 2021-02-11 12:04:41
问题 λ npm -g install firebase npm ERR! Unexpected end of JSON input while parsing near '...9gwBD9c+ThTWWmNBXcfJZ' npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\2nchy\AppData\Roaming\npm-cache\_logs\2020-07-13T18_19_46_173Z-debug.log I increased timeout seconds in .npmrc to 12,000 and downgraded npm to 6.3.17 , cleared the cache as it was suggested and even installed it from an empty directory but still getting an almost same error UPDATE Uninstalled nodejs and

Yarn Berry - Run a Node Script Directly

☆樱花仙子☆ 提交于 2021-02-11 12:01:28
问题 Yarn berry (v2) got rid of node_modules (which I really love) by introducing pnp. However, scripts executed by node directly don't understand pnp modules, so you have to use yarn to run such a script. Is there some way (e.g. a require script like ts-node provides) so that I can still use node to launch my script that requires pnp modules? Background is that I want to configure the Mocha Sidebar extension for VS Code to support pnp. I can add configure node options there and specify files that

Retrieving Images stored in Mongodb with Nodejs

雨燕双飞 提交于 2021-02-11 11:59:25
问题 I have small thumbnails stored in a MongoDB collection. While I can extract them with a .findOne() I can not serve them back over an ExpressJS route correctly. I am not storing thumbs on disk as the heroku environment does not guarantee persisted storage. I am not using GridFS as these are thumbs < 16MB. Inserting a a new document into the collection goes something like this: MongoClient.connect(url, function(err, db){ var newImg = fs.readFileSync(req.file.path); var encImg = newImg.toString(

Cannot GET/POST with express Router()

☆樱花仙子☆ 提交于 2021-02-11 11:54:15
问题 So I've been trying to work this out for some time now and I'm missing something here. I'm trying to determine the best practice for setting up routes in Express. I'd like to separate the different routes I have setup by file. I'm trying to use the Express Router module, but I can't get it to work. Here is my main server file: var express = require('express'); var handlebars = require( 'express-handlebars' ); var path = require('path'); var favicon = require('serve-favicon'); var logger =

Retrieving Images stored in Mongodb with Nodejs

十年热恋 提交于 2021-02-11 11:52:45
问题 I have small thumbnails stored in a MongoDB collection. While I can extract them with a .findOne() I can not serve them back over an ExpressJS route correctly. I am not storing thumbs on disk as the heroku environment does not guarantee persisted storage. I am not using GridFS as these are thumbs < 16MB. Inserting a a new document into the collection goes something like this: MongoClient.connect(url, function(err, db){ var newImg = fs.readFileSync(req.file.path); var encImg = newImg.toString(