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

Dumping context.Context() doesn't show useful info #30

Open
rskumar opened this issue Aug 18, 2019 · 6 comments
Open

Dumping context.Context() doesn't show useful info #30

rskumar opened this issue Aug 18, 2019 · 6 comments

Comments

@rskumar
Copy link

rskumar commented Aug 18, 2019

Code:
litter.Dump(r.Context()) where r is a http.Request.

Output

&context.valueCtx{
  Context: &context.valueCtx{
    Context: &context.valueCtx{
      Context: &context.valueCtx{
        Context: &context.valueCtx{
          Context: &context.valueCtx{ // p2
            Context: &context.valueCtx{
              Context: &context.cancelCtx{
                Context: &context.cancelCtx{
                  Context: &context.valueCtx{
                    Context: &context.valueCtx{
                      Context: &0,
                    },
                  },
                },
              },
            },
          },
        },
      },
    },
  },
}

While github.com/davecgh/go-spew does show Values and other properties set in Context.

@atombender
Copy link
Member

Does Spew handle contexts as a special case?

@rskumar
Copy link
Author

rskumar commented Aug 23, 2019

I didn't find any reference to context.Context in their code (any import). So just a quick guess, maybe their introspection throgh reflect giving inner values. I will try later to debug and check their flow.

@atombender
Copy link
Member

Litter's default options hide private fields. Tried using litter.Options{HidePrivateFields: false}.Dump(ctx)?

@rskumar
Copy link
Author

rskumar commented Aug 25, 2019

Tried litter.Options{HidePrivateFields: false}.Dump(ctx) with http.Request Context, and it started spewing values infinitely. I think there may be circular ref which its following and never stops.

@atombender
Copy link
Member

That sounds like a bug, indeed. Can you file a separate issue with example code? Thanks!

@atombender
Copy link
Member

@rskumar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants