Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SebastienGllmt opened this issue Dec 14, 2024 · 0 comments
Open

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

SebastienGllmt opened this issue Dec 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@SebastienGllmt
Copy link

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 SebastienGllmt added the bug Something isn't working label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant