tslog icon indicating copy to clipboard operation
tslog copied to clipboard

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

Open SebastienGllmt opened this issue 11 months ago • 0 comments
trafficstars

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/[email protected]/node_modules/tslog/dist/esm/runtime/nodejs/index.js:57:111)
    at getCallerStackFrame (file:///home/my-project/node_modules/.deno/[email protected]/node_modules/tslog/dist/esm/runtime/nodejs/index.js:32:12)
    at Object.getMeta (file:///home/my-project/node_modules/.deno/[email protected]/node_modules/tslog/dist/esm/runtime/nodejs/index.js:28:48)
    at Logger._addMetaToLogObj (file:///home/my-project/node_modules/.deno/[email protected]/node_modules/tslog/dist/esm/BaseLogger.js:270:56)
    at Logger.log (file:///home/my-project/node_modules/.deno/[email protected]/node_modules/tslog/dist/esm/BaseLogger.js:85:20)
    at Logger.info (file:///home/my-project/node_modules/.deno/[email protected]/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

SebastienGllmt avatar Dec 14 '24 05:12 SebastienGllmt