Skip to content

logger instantiates itself with default settings, causing crash on server environments that do not allow file write permissions #6179

Closed
@kevflynn

Description

@kevflynn

Issue Description

When you import the parse-server sdk, the logger file instantiates the file logger with default settings, causing the nodejs application to crash if the file system doesn't allow write permissions. This is irrespective of instantiating parse-server with custom config. The problem appears to be in the logger.js file on the line:

let logger = defaultLogger();

Steps to reproduce

  1. Create a 'logs' directory with read only permission at the base of the project directory './logs'
  2. Import the parse-server module with express running
  3. The nodejs/express server will crash because the './logs' directory is read only.

Expected Results

The server should run and the logger should only instantiate once I instantiate the parse-server with optional config settings

Actual Outcome

The logger is instantiated even before I instantiate the parse-server and have a chance to pass my own config settings causing a crash if write permissions are not allowed

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 3.9.0
    • Operating System: Parse server hosted by google app engine nodejs standard environment
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Google App Engine Standard Environment, or localhost without file write permissions

Logs/Trace

{ insertId: "5dbc64ea00010957b7762996" labels: { clone_id: "00c61b117c37e953a744445117cca35dda5c28e7dddc8cd7e6c4936a7ef8cda1c3d442bca9" } logName: "projects/communityroot/logs/stderr" receiveTimestamp: "2019-11-01T17:01:30.156658889Z" resource: { labels: { module_id: "api" project_id: "communityroot" version_id: "20191101t120829" zone: "us17" } type: "gae_app" } textPayload: "Error: EROFS: read-only file system, mkdir '/srv/logs/' at Object.mkdirSync (fs.js:757:3) at /srv/node_modules/file-stream-rotator/FileStreamRotator.js:515:20 at Array.reduce (<anonymous>) at mkDirForFile (/srv/node_modules/file-stream-rotator/FileStreamRotator.js:503:27) at Object.FileStreamRotator.getStream (/srv/node_modules/file-stream-rotator/FileStreamRotator.js:421:5) at new DailyRotateFile (/srv/node_modules/winston-daily-rotate-file/daily-rotate-file.js:83:57) at configureTransports (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLogger.js:41:27) at configureLogger (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLogger.js:109:3) at new WinstonLoggerAdapter (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLoggerAdapter.js:19:42) at defaultLogger (/srv/node_modules/parse-server/lib/logger.js:24:19) at Object.<anonymous> (/srv/node_modules/parse-server/lib/logger.js:28:14) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)" timestamp: "2019-11-01T17:01:30.067927Z" }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions