RMko
RMko•5mo ago

PermissionDenied while using ioredis npm package

Hello, I'm facing an issue with an npm library ioredis (https://github.com/redis/ioredis). For some reason, when I tried to initialize a new Redis client using this package, I received an error: error: Uncaught PermissionDenied: Requires env access, run again with the --allow-env flag. No exact env variable is specified in the log. Yes, it works when I allow env globally, but for my system, I would like to avoid allowing all env variables. So, the question is, how can I check which env variables are accessed by this package, if any? How can I debug this issue and what should i put as allow env ?
6 Replies
marvinh.
marvinh.•5mo ago
These are all the environment variables the ioredis package reads from (including intests and other files not published to npm) https://github.com/search?q=repo%3Aredis%2Fioredis%20process.env&type=code
RMko
RMko•5mo ago
@marvinh. Thank you for your suggestion. After trying list all env variables into --allow-env, it didn't resolve the issue. Adding stacktrace maybe can help: at Object.toObject (ext:runtime/30_os.js:97:16) at Object.ownKeys (ext:deno_node/_process/process.ts:59:41) at Function.keys (<anonymous>) at Object.<anonymous> (file:///deno-dir/npm/registry.npmjs.org/debug/4.3.4/src/node.js:124:30) at Object.<anonymous> (file:///deno-dir/npm/registry.npmjs.org/debug/4.3.4/src/node.js:265:4) at Module._compile (node:module:733:34) at Object.Module._extensions..js (node:module:747:10) at Module.load (node:module:658:32) at Function.Module._load (node:module:539:12) at Module.require (node:module:677:19) Error 1
marvinh.
marvinh.•5mo ago
Can you share the full command including the --allow-env bit?
RMko
RMko•5mo ago
Sure, here is the command:
deno run \
--allow-env=REDIS_PORT,NODES,PORT,KEYS,NODES,redisPort,redisEndpoint,redisUsername,redisPW,ITERATIONS,BATCH_SIZE,DEBUG,DENOAPP_PORT \
--allow-net \
denoapp/app.ts
deno run \
--allow-env=REDIS_PORT,NODES,PORT,KEYS,NODES,redisPort,redisEndpoint,redisUsername,redisPW,ITERATIONS,BATCH_SIZE,DEBUG,DENOAPP_PORT \
--allow-net \
denoapp/app.ts
marvinh.
marvinh.•5mo ago
The command looks correct, even if that list of environment variables seems a bit excessive if I may say so 😄 Is there an error message thrown or is Error 1 all there is? Do you have a code snippet that reproduces the error? I'm not entirely sure why it's failing yet. I would've assumed there to be an error message as well
RMko
RMko•5mo ago
When it comes to the code: I have simple Singleton redis client:
import { Redis } from "npm:ioredis@5.3.2";

export class RedisClient {
private static instance: RedisClient;
private readonly client: Redis;

private constructor() {
// this client initialization is causing the issue
this.client = new Redis({
port: 6379,
host: "172.17.0.1",
db: 0,
});
}

public static getInstance(): RedisClient {
if (!RedisClient.instance) {
RedisClient.instance = new RedisClient();
}
return RedisClient.instance;
}
}
import { Redis } from "npm:ioredis@5.3.2";

export class RedisClient {
private static instance: RedisClient;
private readonly client: Redis;

private constructor() {
// this client initialization is causing the issue
this.client = new Redis({
port: 6379,
host: "172.17.0.1",
db: 0,
});
}

public static getInstance(): RedisClient {
if (!RedisClient.instance) {
RedisClient.instance = new RedisClient();
}
return RedisClient.instance;
}
}
Regarding the error, there is only the i'm executiing line in the Makefile I'm using for my project: make: *** [Makefile:42: dev-denoapp] Error 1
More Posts
Is there a way to obtain Deno.cron schedule info?Deploy lists the registered cron jobs with name, schedule, last run and next run. Is there a programVisual Studio Code Deno does not use node typesI'm trying to use the "esquery" node library with its types, but for any reason Deno ignores the typDrop permissionsI'd like to harden my deno app a bit, but specifying permissions manually gets repetitive. Is there New fresh project comes out of the box with errorsI created a new fresh project on linux, I am using VsCode and im getting many errors although the prIs there a deno function for inputting prompt reply without pressing enter?Normally, one has to press enter for the input to be accepted. I was wondering if there was a versioSetting Deno.Command priority and affinity (on windows)Is it possible to set a tasks / commands priority and affinity directly? Code: ```ts await new DenoIs there a way to write a Deno.AtomicCheck that succeeds for any non-null versionstamp?You can write a Deno.AtomicCheck that fails if the versionstamp for a key-value pair in the KV storeImportTypeScript API + get value of `compilerOptions` with default options from `tsconfig.json`?Hello, I'm trying to figure out the proper way to do a few things: 1. What's the correct way to impHow to override the version from a dependency of a project's dependency from npmI'm currently using react-pdf as a dependency, react-pdf uses fontkit as a dependency, and fontkit uHow to publish global types with JSR?I was trying to republish my npm package with JSR via npm jsr package. It all went well with one exc