I have integrated my loopback application with appDynamics library and all the middlewares are not firing from then on.
Used the debug command - DEBUG=* npm start to get the logs and found these logs coming up.
All the middlewares declared through middleware.json and imperatively through app.middleware() command are having this error message - No matching layer found
Any idea what's going wrong here - Which loopback package is responsible for express routing implementation
2020-07-10T15:23:11.241Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:boot:executor Configuring middleware "/usr/nodejs/njsDT_SIT/apps/wlpn/ob-cof-funds-confirmation-consents-channel/package/node_modules/compression"
2020-07-10T15:23:11.243Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:app use initial compression
2020-07-10T15:23:11.244Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT express:router use [] compression
2020-07-10T15:23:11.245Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT express:router:layer new []
2020-07-10T15:23:11.245Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:app No matching layer is found for initial compression
2020-07-10T15:23:11.245Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:boot:executor Configuring middleware "/usr/nodejs/njsDT_SIT/apps/wlpn/ob-cof-funds-confirmation-consents-channel/package/node_modules/loopback-context/server/middleware/per-request.js" 2020-07-10T15:23:11.246Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:app use initial perRequestContext
2020-07-10T15:23:11.253Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT express:router use [] perRequestContext
2020-07-10T15:23:11.254Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT express:router:layer new []
2020-07-10T15:23:11.254Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:app No matching layer is found for initial perRequestContext
2020-07-10T15:23:11.254Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:boot:executor Configuring middleware "/usr/nodejs/njsDT_SIT/apps/wlpn/ob-cof-funds-confirmation-consents-channel/package/node_modules/cors"
2020-07-10T15:23:11.254Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:app use initial corsMiddleware
2020-07-10T15:23:11.254Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT express:router use [] corsMiddleware
2020-07-10T15:23:11.254Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT express:router:layer new []
2020-07-10T15:23:11.254Z - : pid:36871 worker:1 Fri, 10 Jul 2020 15:23:11 GMT loopback:app No matching layer is found for initial corsMiddleware```
Related
I am working on an event stream system. And my solution is: api-gatway->firehose data stream->data stream delivery->s3.
1.Send a json request(action is PUT) to api-getway
2.Integrate the request with Kinesis service
3.Valid data in the template mapping of the Integration Request
4.Delivery the data to data stream by firehose data delivery
5.Consume the stream and save into S3
It works with below data
1.Request data
{
"Data" : "this is a test"
}
2.Template mapping code of the Integration Request with firehose
{
"StreamName" : "Stream",
"Data" : "$util.base64Encode($input.json('$.Data'))",
"PartitionKey" : "1"
}
Execution log for request 4ad5f3a1-da7d-436f-bd3f-879ba045c622
Fri Jan 15 15:14:19 UTC 2021 : Starting execution for request: 4ad5f3a1-da7d-436f-bd3f-879ba045c622
Fri Jan 15 15:14:19 UTC 2021 : HTTP Method: PUT, Resource Path: /record
Fri Jan 15 15:14:19 UTC 2021 : Method request path: {}
Fri Jan 15 15:14:19 UTC 2021 : Method request query string: {}
Fri Jan 15 15:14:19 UTC 2021 : Method request headers: {}
Fri Jan 15 15:14:19 UTC 2021 : Method request body before transformations: {
"property":"1",
"name":"name"
}
Fri Jan 15 15:14:19 UTC 2021 : Endpoint request URI: https://kinesis.us-east-1.amazonaws.com/?Action=PutRecord
Fri Jan 15 15:14:19 UTC 2021 : Endpoint request headers: {Authorization=***************************************************************************************************************************************************************************************************************************************************************************************9bb292, X-Amz-Date=20210115T151419Z, x-amzn-apigateway-api-id=450acvde3l, Accept=application/json, User-Agent=AmazonAPIGateway_450acvde3l, X-Amz-Security-Token=IQoJb3JpZ2luX2VjEEAaCXVzLWVhc3QtMSJHMEUCIQC7W693nrtuUGrgUvOpn+PUKTRYTGAzRYVSWUPKoAc4eAIgGp/uH4yV/vynaMQUBNEBTwP79m0P9nVfCmw9CMWjY0Mq5QIIGBACGgw1MzUxMTE0MzMzNDAiDKy2z/4lnGJJJAWaOyrCAnANknvMUIbvf9diTZ4qYsdJ3LjETy9hE0f9pUZTBh7aKRjn2y4hbZc/oXGpsmHcgsgJAlIGD51gD0O5LR+N2EKjQeeo5GijkYvZvdbmxVRAZR27EhFzujCk3okePxAzVb3SeCQDWrBnEWn2VwqX4Y75QWwOgL8ZfcuxNKF/wbks0ukPFBo0p68KQ24PIXOYGMs9IAxHYa195+5mUMSi5Av62QKPpBbUAgZ2IJt9EKvRKyLYCs5XzS4lPCgsIbwouVB38f6UQKdQ9XsmD0cX04ODkdj2/0GHne6ufar7nANd3o08PmALd9mXK4z4gt/OxkZUe2AVLXvNQ4IodzW0WOUe1nFvq6YxpveDVfXKDRSK [TRUNCATED]
Fri Jan 15 15:14:19 UTC 2021 : Endpoint request body after transformations: {
"StreamName" : "EventStream",
"Data" : "IiI=",
"PartitionKey" : "1"
}
Fri Jan 15 15:14:19 UTC 2021 : Sending request to https://kinesis.us-east-1.amazonaws.com/?Action=PutRecord
Fri Jan 15 15:14:19 UTC 2021 : Received response. Status: 200, Integration latency: 21 ms
Fri Jan 15 15:14:19 UTC 2021 : Endpoint response headers: {x-amzn-RequestId=c028bf47-0059-8b93-9853-0cccfda9a977, x-amz-id-2=L15V+8AS8gN3HxJwiz0qVqi/UJn2xSWueRMnXdhqgjFw6TeuaRlYX62DZK9pa+O1PcKopTP55aHRLdhX0cQwovKefVpiuRtv, Date=Fri, 15 Jan 2021 15:14:19 GMT, Content-Type=application/x-amz-json-1.1, Content-Length=110}
Fri Jan 15 15:14:19 UTC 2021 : Endpoint response body before transformations: {"SequenceNumber":"49614572211779959518343530489315214421429290892684951554","ShardId":"shardId-000000000000"}
Fri Jan 15 15:14:19 UTC 2021 : Method response body after transformations: {"SequenceNumber":"49614572211779959518343530489315214421429290892684951554","ShardId":"shardId-000000000000"}
Fri Jan 15 15:14:19 UTC 2021 : Method response headers: {X-Amzn-Trace-Id=Root=1-6001b14b-bbccae126175224317a10a4e, Content-Type=application/json}
Fri Jan 15 15:14:19 UTC 2021 : Successfully completed execution
Fri Jan 15 15:14:19 UTC 2021 : Method completed with status: 200
But does not work with below:
1.Request data
{
"Data" : {
"property":"1",
"name":"name"
}
}
2.Template mapping code of the Integration Request with firehose
{
"StreamName" : "Stream",
"Data" : {
"property" : $input.json('$.property'),
"name" : $input.json('$.name')
},
"PartitionKey" : "1"
}
Execution log for request 05b707cc-d95c-40bf-8b75-375048697414
Fri Jan 15 15:39:34 UTC 2021 : Starting execution for request: 05b707cc-d95c-40bf-8b75-375048697414
Fri Jan 15 15:39:34 UTC 2021 : HTTP Method: PUT, Resource Path: /record
Fri Jan 15 15:39:34 UTC 2021 : Method request path: {}
Fri Jan 15 15:39:34 UTC 2021 : Method request query string: {}
Fri Jan 15 15:39:34 UTC 2021 : Method request headers: {}
Fri Jan 15 15:39:34 UTC 2021 : Method request body before transformations: {
"property":"1",
"name":"name"
}
Fri Jan 15 15:39:34 UTC 2021 : Endpoint request URI: https://kinesis.us-east-1.amazonaws.com/?Action=PutRecord
Fri Jan 15 15:39:34 UTC 2021 : Endpoint request headers: {Authorization=***************************************************************************************************************************************************************************************************************************************************************************************a43c70, X-Amz-Date=20210115T153934Z, x-amzn-apigateway-api-id=450acvde3l, Accept=application/json, User-Agent=AmazonAPIGateway_450acvde3l, X-Amz-Security-Token=IQoJb3JpZ2luX2VjEEAaCXVzLWVhc3QtMSJFMEMCHw0tTLi/gwtxUjwAQSl/CIY8aie2nmayl+Qsm6/i520CID9iXCFafaQTh4YqE1/tzvKgMO5IlYgFJrcNbAQB2Nc+KuUCCBkQAhoMNTM1MTExNDMzMzQwIgxeE22ch5hdFy3nB+UqwgJyKnQpnLuEY3zpcbRdEO5jks7yfx2+o1xfIz9Kga0S1PojPfzxh5aD/PthhP8D0jutv96ZVe8p52TwfSnv/z3YeDCFzsnw/U9kGFzGVt1pY2JMB4sg1vU7li8pFP/qiUQ3QA8cXbp4nWeE3kQGlPG4pjH0MsOvowTxM8G6yKosvCdD8fVyCJxWIjFnn1+dK9GGV/MnZlnaVqc57z0n0nrHgLjxBzDcDKJ5/xrgcqcYmUETFj8NyDJ9ESzCp0PhKJV9tGF4LgxbAgffe2Yw/3qpQyB6JNqJrZEczADp3gL0rjIBXhbnx5Yizs9MBMtoB9L22mAwEeqJRx4lK12wOqQZ5+0homLCugauYVoy3juNv/zW [TRUNCATED]
Fri Jan 15 15:39:34 UTC 2021 : Endpoint request body after transformations: {
"StreamName" : "EventStream",
"Data" : {
"property" : "1",
"name" : "name"
},
"PartitionKey" : "1"
}
Fri Jan 15 15:39:34 UTC 2021 : Sending request to https://kinesis.us-east-1.amazonaws.com/?Action=PutRecord
Fri Jan 15 15:39:34 UTC 2021 : Received response. Status: 400, Integration latency: 2 ms
Fri Jan 15 15:39:34 UTC 2021 : Endpoint response headers: {x-amzn-RequestId=cc937c57-744b-fca2-94e8-c5214b4386dd, x-amz-id-2=fqg8MLIbHOfeeFXp6wpii3l4yl32mI/5RyTwYQyzw9/OqpdLNqCBvBbTp8x7Q4YWAroefbfHb5IUEYeD68SQqh2bq87nL4vp, connection=close, Date=Fri, 15 Jan 2021 15:39:34 GMT, Content-Type=application/x-amz-json-1.1, Content-Length=99}
Fri Jan 15 15:39:34 UTC 2021 : Endpoint response body before transformations: {"__type":"SerializationException","Message":"Start of structure or map found where not expected."}
Fri Jan 15 15:39:34 UTC 2021 : Method response body after transformations: {"__type":"SerializationException","Message":"Start of structure or map found where not expected."}
Fri Jan 15 15:39:34 UTC 2021 : Method response headers: {X-Amzn-Trace-Id=Root=1-6001b736-328415f2db20383946bffd9e, Content-Type=application/json}
Fri Jan 15 15:39:34 UTC 2021 : Successfully completed execution
Fri Jan 15 15:39:34 UTC 2021 : Method completed with status: 200
reference: https://www.youtube.com/watch?v=0UxiV5sUlcA
My bad and I forgot to encode in template mapping.
The code should be:
{
"StreamName" : "Stream",
"Data" : "$util.base64Encode(
{
"property" : $input.json('$.property'),
"name" : $input.json('$.name')
}
),
"PartitionKey" : "1"
}
This has been working for months, I don't think I've changed anything, but with express.static, browsers show "pending" infinitely.
Here's the code:
const app = express();
app.use('/', express.static(
path.resolve('./build/web'),
{ dotfiles: 'allow' },
));
Here's a screenshot of Chrome's network tab:
Only main.js has this issue. If I open the file directly, it works. This also occurs in Firefox, so I suspect it's a Node/Express issue. I have adblockers turned off.
I ran DEBUG=* node server.js and the output is:
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send stat "/path/build/web/post/101"
[0] [1] /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router dispatching GET /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router query : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router expressInit : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router jsonParser : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT body-parser:json skip empty body
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router urlencodedParser : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT body-parser:urlencoded skip empty body
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router cookieParser : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router corsMiddleware : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router trim prefix (/js/main.js) from url /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router <anonymous> /js/main.js : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router serveStatic : /js/main.js?v=223
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send stat "/path/build/web/js/main.js"
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send pipe "/path/build/web/js/main.js"
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send accept ranges
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send cache-control public, max-age=0
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send modified Thu, 27 Aug 2020 06:50:21 GMT
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send etag W/"180a43-1742eae7e13"
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT send content-type application/javascript
[0] [1] Thu, 27 Aug 2020 07:02:15 GMT express:router dispatching GET /css/main.css?v=223
This output looks normal to me.
I tried:
clearing cache
incognito
closing/re-opening Chrome devtools
closing/re-opening Chrome
restarting the server
After several attempts with the above, the issue goes away for a few hours, but I don't think any particular action consistently fixes the issue.
Any ideas what might be the culprit?
I encountered the same issue on node v14.8.0 and v14.9.0 with the latest published version of Express and the latest code on their master branch. Using v12.16.2 it works again.
I want to disable some logs (express:router) from express code which use pm2 to run.
Current logs are as follows
GMT express:router dispatching GET /healthcheck
10|consumer | Wed, 10 Oct 2018 19:40:04 GMT express:router query : /healthcheck
10|consumer | Wed, 10 Oct 2018 19:40:04 GMT express:router expressInit : /healthcheck
10|consumer | Wed, 10 Oct 2018 19:40:04 GMT express:router corsMiddleware : /healthcheck
10|consumer | Wed, 10 Oct 2018 19:40:04 GMT express:router jsonParser : /healthcheck
10|consumer | Wed, 10 Oct 2018 19:40:04 GMT body-parser:json skip empty body
10|consumer | Wed, 10 Oct 2018 19:40:04 GMT express:router urlencodedParser : /healthcheck
10|consumer | Wed, 10 Oct 2018 19:40:04 GMT body-parser:urlencoded skip empty body
I pass /dev/null to error_file or out_file to disable logs saving -
not works i can still see the logs
Run pm2 using command - pm2 start consumer -o "/dev/null" -e "/dev/null" - Not works.
I run it using DEBUG=express.* node index.js - not worked.
I manage to get it done by adding following environment var
process.env.DEBUG=false
My purpose is to expire a token after 1hr (3600 secs). While trying with nodejs speakeasy the token is getting invalidated much before that. The below logs are for "1, 10 and 60 minutes" and that also getting invalidated muche before the 1 minute. Max of the time I am getting inconsistent results.
Partial code snippet
let secret = speakeasy.generateSecret({
length: 10
});
let seconds= 3600; //1Hr
let token = speakeasy.totp({
secret: secret.base32,
step: seconds
});
let otp = {
"secret": secret.base32.toString(),
"token": token
};
function checkOTP(otp) {
let verified = speakeasy.totp.verify({
secret: otp.secret,
token: otp.token,
step: seconds
});
return verified;
}
Am I doing something wrong? Few console logs from a sample script:
For 1 minute - Invalidated before 18secs
[ Fri Dec 08 2017 09:16:18 GMT-0800 (Pacific Standard Time) ](true) 9:16:59 AM
[ Fri Dec 08 2017 09:16:18 GMT-0800 (Pacific Standard Time) ](false) 9:17:00 AM
For 10Mins - Invalidated before 7minutes
[ Fri Dec 08 2017 09:18:28 GMT-0800 (Pacific Standard Time) ](true) 9:19:59 AM
[ Fri Dec 08 2017 09:18:28 GMT-0800 (Pacific Standard Time) ](true) 9:19:59 AM
[ Fri Dec 08 2017 09:18:28 GMT-0800 (Pacific Standard Time) ](true) 9:19:59 AM
[ Fri Dec 08 2017 09:18:28 GMT-0800 (Pacific Standard Time) ](true) 9:19:59 AM
[ Fri Dec 08 2017 09:18:28 GMT-0800 (Pacific Standard Time) ](false) 9:20:00 AM
For 1Hr - Invalidated before 7minutes
[ Fri Dec 08 2017 11:07:01 GMT-0800 (Pacific Standard Time) ](true) 11:56:41 AM
[ Fri Dec 08 2017 11:07:01 GMT-0800 (Pacific Standard Time) ](true) 11:56:43 AM
[ Fri Dec 08 2017 11:07:01 GMT-0800 (Pacific Standard Time) ](false) 12:00:37 PM
What is the appropriate way to validate within the above window?
From the readme of speakeasy it looks like your token parameters are wrong:
var token = speakeasy.totp({
secret: secret.base32,
encoding: 'base32',
time: 1453667708 // You have this as 'step' not 'time'
});
While playing with NodeJS in Webstorm I came to a point where 'suddenly' this output appeared. Until now I didn't have all the 'time .. express:router .. ' lines:
"C:\Program Files (x86)\JetBrains\WebStorm 9.0.1\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug-brk=49723 --nolazy srv.js
debugger listening on port 49723
Tue, 06 Jan 2015 11:15:06 GMT express:router:route new *
Express server listening 0.0.0.0:80
Tue, 06 Jan 2015 11:15:06 GMT express:router:layer new *
Tue, 06 Jan 2015 11:15:06 GMT express:router:route get *
Tue, 06 Jan 2015 11:15:06 GMT express:router:layer new /
Tue, 06 Jan 2015 11:15:06 GMT express:application compile etag weak
Tue, 06 Jan 2015 11:15:06 GMT express:application compile query parser extended
Tue, 06 Jan 2015 11:15:06 GMT express:application compile trust proxy false
Tue, 06 Jan 2015 11:15:06 GMT express:application booting in development mode
Tue, 06 Jan 2015 11:15:06 GMT express:router use / query
Tue, 06 Jan 2015 11:15:06 GMT express:router:layer new /
Tue, 06 Jan 2015 11:15:06 GMT express:router use / expressInit
I try to understand which setting or function is responsible for this. My simple code:
'use strict';
var appEnv = 'development'; //'production'
var appPort = 80;
var path = require('path');
var http = require('http');
var express = require('express');
var bodyParser = require('body-parser');
var resource = require('express-resource');
var session = require('express-session');
// here the mentioned output appears first during step-by-step debugging:
var appRouter = require('./routes/index');
var user = require('./routes/user');
...
I guess it's not a Node then more a Webstorm question, right? Probably there is a setting for this ... which I didn't find. Maybe there is a key combination I hit by mistake?
Thanks for any help!
It's a Webstorm Debugger console info. U might have clicked on "debug the project" option in your IDE.
These messages are logged by Express when running in debug mode. See http://expressjs.com/guide/debugging.html