Skip to content

Bug: crash in Deno if process.cwd permission isn't allowed #309

@SebastienGllmt

Description

@SebastienGllmt

Describe the bug

Currently, tslog will request the process.cwd (even if it's not required for the log format) used. You can see this here

The problem with this is that some runtimes like Deno only allow reading process.cwd if you have the --allow-read permission enabled. It's unfortunate that I have to give permission to my entire application to read the file system on the user's machine even if I'm just printing logs to console

To Reproduce

  1. Setup a deno repo with tslog
  2. Use deno run but don't pass in the --allow-read flag
  3. Try to log any statement

Expected behavior

If I'm not displaying the cwd in the log format or using any transport that accesses the file system, logs should be printed to console without error

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

NotCapable: Requires read access to <CWD>, run again with the --allow-read flag
    at Process.cwd (ext:deno_fs/30_fs.js:151:10)
    at stackLineToStackFrame (file:///home/my-project/node_modules/.deno/tslog@4.9.3/node_modules/tslog/dist/esm/runtime/nodejs/index.js:57:111)
    at getCallerStackFrame (file:///home/my-project/node_modules/.deno/tslog@4.9.3/node_modules/tslog/dist/esm/runtime/nodejs/index.js:32:12)
    at Object.getMeta (file:///home/my-project/node_modules/.deno/tslog@4.9.3/node_modules/tslog/dist/esm/runtime/nodejs/index.js:28:48)
    at Logger._addMetaToLogObj (file:///home/my-project/node_modules/.deno/tslog@4.9.3/node_modules/tslog/dist/esm/BaseLogger.js:270:56)
    at Logger.log (file:///home/my-project/node_modules/.deno/tslog@4.9.3/node_modules/tslog/dist/esm/BaseLogger.js:85:20)
    at Logger.info (file:///home/my-project/node_modules/.deno/tslog@4.9.3/node_modules/tslog/dist/esm/index.js:26:22)
    at file:///home/my-project/packages/my-package/log/src/tslog.ts:88:18
  name: "NotCapable"
}

Node.js Version

Deno 2.1.3

OS incl. Version

Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions