debug icon indicating copy to clipboard operation
debug copied to clipboard

DEBUG_DEPTH not working

Open anishkny opened this issue 5 years ago • 18 comments

DEBUG_DEPTH env var has no effect. I tried values of 10, 100, null. No matter what I always get the following display:

2020-02-08T22:17:01.423Z SCOPE STRING [ { email: '[email protected]', vars: [ [Object] ] } ]

My invocation:

debug('STRING', targetObj);

anishkny avatar Feb 08 '20 22:02 anishkny

Noticed this also. Looks like it is defaulting to 3 and not allowing an override...

Any fix in the works?

chriskinsman avatar Jul 08 '20 00:07 chriskinsman

Yep looks like a regression somewhere.

Qix- avatar Jul 08 '20 19:07 Qix-

Can you test with npm i --no-save visionmedia/debug#fix/depth?

Qix- avatar Jul 08 '20 19:07 Qix-

Started down the git blame rabbit hole. If that branch fixes it, then this has been broken for years. Amazing.

Qix- avatar Jul 08 '20 19:07 Qix-

Looks like fix is effective. Any place to add unit tests for this?

I should have noted it reproduces only when deep object is the second argument to the debug function, e.g.

// index.js
require('debug')('FOO')('something', {
  x: 1,
  y: { a: 2, b: 3, c: { a: 1, b: { a: 1, b: { a: 1, b: { a: 1 } } } } },
});

Before fix:

$ DEBUG=FOO DEBUG_DEPTH=40 node index.js
  FOO something { x: 1, y: { a: 2, b: 3, c: { a: 1, b: [Object] } } } +0ms

After fix:

$ DEBUG=FOO DEBUG_DEPTH=40 node index.js
  FOO something {
  x: 1,
  y: {
    a: 2,
    b: 3,
    c: {
      a: 1,
      b: { a: 1, b: { a: 1, b: { a: 1 } } }
    }
  }
} +0ms

anishkny avatar Jul 08 '20 22:07 anishkny

I should have noted it reproduces only when deep object is the second argument to the debug function, e.g.

Yeah that's much less simple to fix; there are a few bugs surrounding this. v5 is going to be a rewrite for the most part, so a lot of this will get addressed then.

Glad to know it works now (mostly); I'll commit it in sometime soon. Thank you very much for testing @anishkny :)

Qix- avatar Jul 08 '20 22:07 Qix-

What is the status on this issue ?

I noticed it recently in our production container, but that's a bit more tricky since I can't reproduce the problem locally.

Same value of DEBUG_DEPTH in both case (10). Trying to decrement or increment it locally seems to produce the expected effect, while any value in our container does nothing (looks like it's stucked to 3), so I'm guessing something else is interfering but I wasn't able to find out what yet.

sylver avatar May 21 '21 17:05 sylver

What is the status on this issue?

image

Qix- avatar May 21 '21 17:05 Qix-

@Qix- very useful & constructive, thanks.

Since you clearly need me to clarify my question:

Giving this issue is opened for more than a year, and no news since Jul 9, 2020, would you be so kind to provide some update on its resolution ?

Thanks

sylver avatar May 21 '21 18:05 sylver

There is no update.

Qix- avatar May 22 '21 07:05 Qix-

@Qix- Thanks.

Thing is, you apparently already had a fix a year ago and stated in the last update on this issue :

[...] I'll commit it in sometime soon.

I'm wondering what's holding you back for so long and if the project is still maintained. Do you or any maintainer on the project would need any help to make it happen ?

sylver avatar May 22 '21 12:05 sylver

@sylver

Thing is, you apparently already had a fix a year ago and stated in the last update on this issue :

Yep.

I'm wondering what's holding you back for so long

Life.

if the project is still maintained.

Yep.

Do you or any maintainer on the project would need any help to make it happen ?

I'm the only active maintainer and I've been struggling to find free time to work on unrelated OSS. The pandemic hit us really hard and we're recovering still.

Qix- avatar May 22 '21 13:05 Qix-

@Qix-

The pandemic hit us really hard and we're recovering still.

Sorry to hear that, hold on there.

I'm the only active maintainer and I've been struggling to find free time to work on unrelated OSS.

That's understandable.

That's not a critical issue anyway, just an annoying one.
But if there's a quick win and I can help to close it with a PR (adding what's missing, unit tests maybe ?), let me know.

sylver avatar May 22 '21 16:05 sylver

@Qix- I have created a PR https://github.com/debug-js/debug/pull/911 for this fix.

It comes with tests as well.

calvintwr avatar Sep 02 '22 08:09 calvintwr

It looks like your fix unfixed itself in the mean time somewhere. Running the test someone mentions above yields this:

DEBUG=FOO DEBUG_DEPTH=40 node bla.js
  FOO something { x: 1, y: { a: 2, b: 3, c: { a: 1, b: [Object] } } } +0ms

As you can see, this stil (again?) prints [Object]

eavdmeer avatar Dec 26 '22 08:12 eavdmeer

It looks like your fix unfixed itself in the mean time somewhere. Running the test someone mentions above yields this:

DEBUG=FOO DEBUG_DEPTH=40 node bla.js
  FOO something { x: 1, y: { a: 2, b: 3, c: { a: 1, b: [Object] } } } +0ms

As you can see, this stil (again?) prints [Object]

My fix wasn't merged. You can try to checkout this branch to see if it works: https://github.com/calvintwr/debug/tree/fix/debug-depth

@Qix- I have created a PR #911 for this fix.

It comes with tests as well.

A new PR is at https://github.com/debug-js/debug/pull/926

calvintwr avatar Feb 12 '23 02:02 calvintwr

Looks like it works as expected now:

$ DEBUG=FOO DEBUG_DEPTH=40 node index.js
  FOO something {
  x: 1,
  y: {
    a: 2,
    b: 3,
    c: {
      a: 1,
      b: { a: 1, b: { a: 1, b: { a: 1 } } }
    }
  }
} +0ms
$ DEBUG=FOO DEBUG_DEPTH=1 node index.js
  FOO something { x: 1, y: { a: 2, b: 3, c: [Object] } } +0ms

eavdmeer avatar Feb 12 '23 10:02 eavdmeer

@Qix- now that the pandemic is over you think you could merge this? :) #926

piboistudios avatar May 15 '23 16:05 piboistudios