As the Insert ID are different, it does not seem the duplicate logs are 
coming from, or being created by Cloud Logging.

Are you only seeing this behaviour after you've deployed? Was it throwing 
duplicate logs while running locally?


On Friday, March 20, 2020 at 7:58:18 AM UTC-4, Denis Maliutenko wrote:
>
> Logs are duplicated for some reason. Check out attached screenshot.
>
> I use one instance and standard environment. 
>
> app.yaml
> runtime: nodejs10
>
> manual_scaling:
>  instances: 1
>
> Also I use NextJs with custom server.
>
> package.json
> {
>    "scripts": {
>        "dev": "node -r dotenv/config server.js dotenv_config_path=.env.dev
> ",
>        "deploy": "gcloud app deploy",
>        "build": "next build ./src",
>        "start": "node -r dotenv/config server.js",
>        "analize": "ANALYZE=true yarn build",
>        "gcp-build": "yarn run build"
>    },
>    "dependencies": {
>        "@google-cloud/debug-agent": "^4.2.2",
>        "@material-ui/core": "^4.1.1",
>        "@material-ui/icons": "^4.2.0",
>        "@material-ui/styles": "^4.5.0",
>        "@next/bundle-analyzer": "^8.1.0",
>        "@svgr/webpack": "^4.3.2",
>        "cassandra-driver": "^4.1.0",
>        "cassandra-store": "^5.0.0",
>        "clsx": "^1.0.4",
>        "crypto": "^1.0.1",
>        "crypto-js": "^3.1.9-1",
>        "dotenv": "^8.0.0",
>        "express": "^4.17.1",
>        "express-session": "^1.16.2",
>        "http-parser-js": "^0.5.2",
>        "isomorphic-unfetch": "^3.0.0",
>        "jsonwebtoken": "^8.5.1",
>        "ldapjs-client": "^0.1.1",
>        "material-table": "^1.52.0",
>        "mobx": "^5.15.4",
>        "mobx-react": "^6.1.8",
>        "mobx-state-tree": "^3.15.0",
>        "next": "^9.3.0",
>        "next-i18next": "^4.2.1",
>        "node-schedule": "^1.3.2",
>        "notistack": "^0.9.9",
>        "passport": "^0.4.1",
>        "passport-auth0": "^1.3.2",
>        "password-generator": "^2.2.0",
>        "path": "^0.12.7",
>        "php-serialize": "^3.0.0",
>        "prop-types": "^15.7.2",
>        "react": "^16.13.0",
>        "react-dom": "^16.13.0",
>        "react-i18next": "^11.3.3",
>        "rijndael-js": "^2.0.0",
>        "sass": "^1.26.2",
>        "uid-safe": "^2.1.5"
>    },
>    "devDependencies": {
>        "@babel/plugin-proposal-class-properties": "^7.5.5",
>        "@babel/plugin-proposal-decorators": "^7.4.4",
>        "babel-eslint": "^10.0.2",
>        "eslint": "^5.16.0",
>        "eslint-config-airbnb": "^17.1.0",
>        "eslint-plugin-import": "^2.18.0",
>        "eslint-plugin-jsx-a11y": "^6.2.1",
>        "eslint-plugin-react": "^7.13.0"
>    }
> }
>
> server.js
> // Next line fixes this issue: 
> https://stackoverflow.com/questions/36628420/nodejs-request-hpe-invalid-header-token
> process.binding('http_parser').HTTPParser = require('http-parser-js').
> HTTPParser;
> const http = require('http');
> const express = require('express');
> const path = require('path');
> const next = require('next');
> const session = require('express-session');
> const bodyParser = require('body-parser');
> // Gcloud
> const gcloudDebugAgent = require('@google-cloud/debug-agent');
> // Auth0
> const uid = require('uid-safe');
> const passport = require('passport');
> // i18n
> const nextI18NextMiddleware = require('next-i18next/middleware').default;
> const nextI18next = require('./src/i18n');
> // Routes
> const auth0Routes = require('./src/routes/auth0-routes');
> const mainRoutes = require('./src/routes/main-routes');
> const twoCheckoutRoutes = require('./src/routes/2checkout-routes');
> // Utils
> // const cassandraSessionStore = 
> require('./src/utils/cassandraSessionStore.utils');
> const { initFortifiUtil } = require('./src/utils/fortifiApi.utils');
> const { initLdapClientUtil } = require('./src/utils/ldapClient.utils');
> const { initAuth0ManagememntUtil } = require(
> './src/utils/auth0ManagementApi.utils');
> const { auth0Strategy } = require('./src/utils/auth0Express.utils');
>
> console.log('process.env.NODE_ENV', process.env.NODE_ENV);
> const isProduction = process.env.NODE_ENV === 'production';
> if (isProduction) gcloudDebugAgent.start({ allowExpressions: true });
>
> Promise.all([
>    initAuth0ManagememntUtil(),
>    initLdapClientUtil(),
>    initFortifiUtil(),
> ])
>    .then(responses => {
>        responses.forEach(({ error }) => {
>            if (error) {
>                console.log('---> ---> Error: Init Utils', error);
>                process.exit(1);
>            } 
>         });
>    });
>
> const app = next({
>    dev: !isProduction,
>    dir: './src',
> });
> const handle = app.getRequestHandler();
>
> const server = express();
> const serverInstance = http.createServer(server);
>
> app.prepare().then(async () => {
>    // enable the use of request body parsing middleware
>    server.use(bodyParser.json());
>    server.use(bodyParser.urlencoded({
>        extended: true
>    }));
>
>     // Need to use explicit define of static folder
>    // because of [dir: './src',] in next initialization
>    server.use('/static', express.static(path.join(__dirname, './static'
> )));
>
>     // translations
>    await nextI18next.initPromise;
>    server.use(nextI18NextMiddleware(nextI18next));
>
>     // Express session management
>    const sessionConfig = {
>        // disabled because of deploy problems on gcloud
>        // store: cassandraSessionStore,
>        secret: uid.sync(18),
>        cookie: {
>            // 24 hours in milliseconds
>            maxAge: 86400 * 1000,
>        },
>        resave: false,
>        saveUninitialized: true,
>    };
>    server.use(session(sessionConfig));
>
>     // Auth0 - Passport configuration`
>    passport.use(auth0Strategy);
>    passport.serializeUser((user, done) => done(null, user));
>    passport.deserializeUser((user, done) => done(null, user));
>
>     // Auth0 - adding Passport and authentication routes
>    server.use(passport.initialize());
>    server.use(passport.session());
>
>     // Routes
>    server.use(auth0Routes);
>    server.use(mainRoutes);
>    server.use(twoCheckoutRoutes);
>
>     // handling everything else with Next.js
>    server.get('*', handle);
>
>     // app server
>    serverInstance.listen(process.env.PORT, (err) => {
>        console.log(err || `Listening on port ${process.env.PORT}`);
>    });
> });
>
>
>
>
>
>
> --
>
> The information contained in this electronic message and any attachments 
> to this message are intended for the exclusive use of the addressee(s) and 
> may contain proprietary, confidential or privileged information. If you are 
> not the intended recipient, you should not disseminate, distribute or copy 
> this e-mail. Please notify the sender immediately and destroy all copies of 
> this message and any attachments. WARNING: Computer viruses can be 
> transmitted via email. The recipient should check this email and any 
> attachments for the presence of viruses. The company accepts no liability 
> for any damage caused by any virus transmitted by this email. 
> www.digitalis.io
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/ce08bdee-4c88-41d7-bbae-e4d1713e847b%40googlegroups.com.

Reply via email to