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

Info needed: BadResource: Bad resource ID #89

Closed
reselbob opened this issue Jun 13, 2020 · 11 comments · Fixed by #94
Closed

Info needed: BadResource: Bad resource ID #89

reselbob opened this issue Jun 13, 2020 · 11 comments · Fixed by #94
Assignees
Labels
bug Something isn't working

Comments

@reselbob
Copy link

Hi:

I run this code and it does indeed consume and report published messages.

      (async function () {
        try{
          for await (const { channel, message } of sub.receive()) {
            handler(message);
          }
        }catch(err){
          console.log(err);
        }

But, I get an error BadResource: Bad resource ID.

Any idea what this means. I will very much appreciate the help.

Thanks in advance.

@ebebbington
Copy link
Member

@keroxp I hope you don't mind me giving input...

@reselbob Can you provide the exact code you used? How you are running/using it? I assume the above is pseudo-code as well as it isn't valid code.

Usually I see Bad Resource ID when a subprocess using Deno.run isn't closed properly or passed invalid values

@reselbob
Copy link
Author

Here is the code: https://github.com/reselbob/denodemo/blob/master/pubbersubber/types/providers/redis.ts

Here is the project it runs within: https://github.com/reselbob/denodemo/tree/master/pubbersubber

Here is the test: https://github.com/reselbob/denodemo/blob/master/pubbersubber/tests/connection_test.ts , starting at line 63:

You need to have rabbitmq and redis running. I've put this all in the test script found here:

https://github.com/reselbob/denodemo/blob/master/pubbersubber/tests/run_tests

Thanks for your attention. Any help will be appreciated a lot! If the error is due some bad programming on my part, which it very well might be, please forgive me.

@ebebbington
Copy link
Member

@reselbob Doesn't seem like any of those links work?

@reselbob
Copy link
Author

Sorry, the repo was private. Now it's not.

@ebebbington
Copy link
Member

No problem! Do you have the error stack it displays too?

@reselbob
Copy link
Author

error: Uncaught BadResource: Bad resource ID 
    at unwrapResponse ($deno$/ops/dispatch_minimal.ts:63:11)
    at Object.sendAsyncMinimal ($deno$/ops/dispatch_minimal.ts:106:10)
    at async Object.read ($deno$/ops/io.ts:39:17)
    at async BufReader._fill (https://deno.land/std@v0.51.0/io/bufio.ts:85:18)
    at async BufReader.readByte (https://deno.land/std@v0.51.0/io/bufio.ts:198:7)
    at async readLine (https://raw.githubusercontent.com/keroxp/deno-redis/master/io.ts:91:15)
    at async readArrayReply (https://raw.githubusercontent.com/keroxp/deno-redis/master/io.ts:141:16)
    at async RedisSubscriptionImpl.receive (https://raw.githubusercontent.com/keroxp/deno-redis/master/pubsub.ts:64:20)
    at async file:///Users/reselbob/Documents/source-tree/denodemo/pubbersubber/types/providers/redis.ts:70:46

@uki00a
Copy link
Member

uki00a commented Jun 20, 2020

@reselbob @ebebbington
Thanks for reporting this issue!
I was able to reproduce the same error.
I'll look into it.

@uki00a
Copy link
Member

uki00a commented Jun 20, 2020

Steps to reproduce

I have a file named mod.ts:

import { connect } from "https://deno.land/x/redis@v0.10.2/redis.ts";

const redis = await connect({ hostname: "localhost" });
const sub = await redis.subscribe("test");

(async () => {
  for await (const { channel, message } of sub.receive()) {
    console.log("channel: " + channel);
    console.log("message: " + message);
  }
})();

redis.close();

When running the mod.ts, the following error occurs:

$ deno run --allow-net ./mod.ts
error: Uncaught BadResource: Bad resource ID 
    at unwrapResponse ($deno$/ops/dispatch_minimal.ts:63:11)
    at Object.sendAsyncMinimal ($deno$/ops/dispatch_minimal.ts:106:10)
    at async Object.read ($deno$/ops/io.ts:39:17)
    at async BufReader._fill (https://deno.land/std@v0.56.0/io/bufio.ts:85:18)
    at async BufReader.readByte (https://deno.land/std@v0.56.0/io/bufio.ts:198:7)
    at async readLine (https://deno.land/x/redis@v0.10.2/io.ts:91:15)
    at async readArrayReply (https://deno.land/x/redis@v0.10.2/io.ts:141:16)
    at async RedisSubscriptionImpl.receive (https://deno.land/x/redis@v0.10.2/pubsub.ts:64:20)
    at async file:///home/uki00a/projects/deno-redis/mod.ts:8:38

Environment

deno 1.1.0
v8 8.4.300
typescript 3.9.2

@uki00a
Copy link
Member

uki00a commented Jun 20, 2020

@reselbob Hi! This problem has been fixed at v0.10.3. Please update to it.

@ebebbington Thanks for your help! It really helps us.

@ebebbington
Copy link
Member

@uki00a Shame I didn't have the time to help out more!

@reselbob
Copy link
Author

I am happy I was able to help. Deno is important as is being able to use Redis with it! Thanks for your attention.

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

Successfully merging a pull request may close this issue.

3 participants