node.js

Is it normal for Node.js' RSS (Resident Set Size) to grow with each request, until reaching some cap?

孤人 提交于 2021-02-18 10:21:30
问题 I've noticed that RSS (Resident Set Size) of my node.js app is growing over time, and considering I'm having a "JS Object Allocation Failed - Out of Memory" error on my server, it seems a likely cause. I set up the following very simple Node app: var express = require('express'); var app = express(); app.get('/',function(req,res,next){ res.end(JSON.stringify(process.memoryUsage())); }); app.listen(8888); By simply holding down the "refresh" hotkey @ http:// localhost:8888/ I can watch the RSS

Getting DOM node text with Puppeteer and headless Chrome

主宰稳场 提交于 2021-02-18 10:15:51
问题 I'm trying to use headless Chrome and Puppeteer to run our Javascript tests, but I can't extract the results from the page. Based on this answer, it looks like I should use page.evaluate(). That section even has an example that looks like what I need. const bodyHandle = await page.$('body'); const html = await page.evaluate(body => body.innerHTML, bodyHandle); await bodyHandle.dispose(); As a full example, I tried to convert that to a script that will extract my name from my user profile on

Getting DOM node text with Puppeteer and headless Chrome

£可爱£侵袭症+ 提交于 2021-02-18 10:15:30
问题 I'm trying to use headless Chrome and Puppeteer to run our Javascript tests, but I can't extract the results from the page. Based on this answer, it looks like I should use page.evaluate(). That section even has an example that looks like what I need. const bodyHandle = await page.$('body'); const html = await page.evaluate(body => body.innerHTML, bodyHandle); await bodyHandle.dispose(); As a full example, I tried to convert that to a script that will extract my name from my user profile on

mongoose query same field with different values

 ̄綄美尐妖づ 提交于 2021-02-18 09:54:28
问题 Is there a way to user mongoose.find({title:'some title'}) to query the same field with multiple values? For example something like this mongoose.find({title:'some title', title:'some other title'}) sends back only documents matching title:'some other title is there a way to accomplish this ? 回答1: You should use the MongoDB $in operator - mongoose.find({title: {$in: ['some title', 'some other title']}}) You provide an array to $in operator and it will return all the documents which have an

mongoose query same field with different values

那年仲夏 提交于 2021-02-18 09:53:20
问题 Is there a way to user mongoose.find({title:'some title'}) to query the same field with multiple values? For example something like this mongoose.find({title:'some title', title:'some other title'}) sends back only documents matching title:'some other title is there a way to accomplish this ? 回答1: You should use the MongoDB $in operator - mongoose.find({title: {$in: ['some title', 'some other title']}}) You provide an array to $in operator and it will return all the documents which have an

Using `instanceof` on objects created with constructors from deep npm dependencies

*爱你&永不变心* 提交于 2021-02-18 09:52:32
问题 Background: I have an npm module that I have common error handling code in, including a custom error: function CustomError () { /* ... */ } CustomError.prototype = Object.create(Error.prototype); CustomError.prototype.constructor = CustomError; module.exports = CustomError; I have some other modules (let's call them 'module-a' and 'module-b' ) which both depend on the error handling module. I also have some code with uses Bluebirds "filtered catch" functionality: doSomething .catch

how to clear warnings in node js while using mongoose

荒凉一梦 提交于 2021-02-18 09:35:42
问题 I'm having a doubt in The Web Developer Bootcamp course from section 29,304 module (node:15807) Warning: Accessing non-existent property 'count' of module exports inside circular dependency (Use node --trace-warnings ... to show where the warning was created) (node:15807) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency (node:15807) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency (node:15807) Warning

how to clear warnings in node js while using mongoose

老子叫甜甜 提交于 2021-02-18 09:29:32
问题 I'm having a doubt in The Web Developer Bootcamp course from section 29,304 module (node:15807) Warning: Accessing non-existent property 'count' of module exports inside circular dependency (Use node --trace-warnings ... to show where the warning was created) (node:15807) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency (node:15807) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency (node:15807) Warning

How can I access a specific folder inside firebase storage from a cloud function?

怎甘沉沦 提交于 2021-02-18 08:40:08
问题 I am using firebase cloud function storage for the first time. I succeeded to perform changes on the default folder by using : exports.onFileUpload = functions.storage.bucket().object().onFinalize(data => { const bucket = data.bucket; const filePath = data.name; const destBucket = admin.storage().bucket(bucket); const file = destBucket.file(filePath); but now I want the function to be triggered from a folder inside the storage folder like this How can I do that? 回答1: There is currently no way

React axios calls to Express API in Heroku deployment

ぃ、小莉子 提交于 2021-02-18 08:39:18
问题 I have a React todo app I built using create-react-app and I built a simple express server to query mongoDB to get all the appointment objects. It works just as expected when I am running it on my machine. The front end spins up on localhost:3000 and the server on localhost:3001 . I use axios to make a get request to localhost:3000/api/appointments to load all the appointments into the App.js state. I uploaded it to Heroku and I got a CORS error on the request. After that, I tried to just use