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

@graphql-tools/load outputs debug logs for any value of DEBUG #4777

Closed
4 tasks
ldiqual opened this issue Oct 25, 2022 · 8 comments · Fixed by #5715
Closed
4 tasks

@graphql-tools/load outputs debug logs for any value of DEBUG #4777

ldiqual opened this issue Oct 25, 2022 · 8 comments · Fixed by #5715

Comments

@ldiqual
Copy link
Contributor

ldiqual commented Oct 25, 2022

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

@graphql-tools/load prints debug logs if process.env.DEBUG is defined (even if empty, 0, or any value irrelevant to graphql-tools). This was introduced in #4752.

When running DEBUG=myapp node app.js with any code that uses @graphql-tools/load, debug logs are dumped into the console and also include incorrect timeEnd labels.

@graphql-tools/load: loadFile /path/to/types.graphql: 80.793ms
@graphql-tools/load: collectFallback /path/to/types.graphql: 80.986ms
@graphql-tools/load: loadFile /path/to/operations.graphql: 85.872ms
@graphql-tools/load: collectFallback /path/to/operations.graphql: 85.959ms
@graphql-tools/load: collectSources queue: 94.184ms
@graphql-tools/load: parseSchema /path/to/operations.graphql: 0.005ms
@graphql-tools/load: parseRawSDL /path/to/operations.graphql: 0.002ms
@graphql-tools/load: useComments /path/to/operations.graphql: 40.366ms
@graphql-tools/load: collectValidSources /path/to/operations.graphql: 0.018ms
@graphql-tools/load: parseSource /path/to/operations.graphql: 40.975ms
@graphql-tools/load: parseSchema /path/to/types.graphql: 0.003ms
@graphql-tools/load: parseRawSDL /path/to/types.graphql: 0.002ms
@graphql-tools/load: useComments /path/to/types.graphql: 31.865ms
@graphql-tools/load: collectValidSources /path/to/types.graphql: 0.006ms
@graphql-tools/load: parseSource /path/to/types.graphql: 32.07ms
@graphql-tools/load: prepareResult: 0.035ms
@graphql-tools/load: loadTypedefs: 168.629ms
(node:15996) Warning: No such label '@graphql-tools/load: loadFile /path/to/types.graphql' for console.timeEnd()
(node:15996) Warning: No such label '@graphql-tools/load: collectFallback /path/to/types.graphql' for console.timeEnd()

To Reproduce

Steps to reproduce the behavior:

  • Load a schema with @graphql-tools/load in your app.ts
  • Run DEBUG=myapp node app.js, it will log things unrelated to your app

Expected behavior

I expect @graphql-tools/load to only log when using DEBUG=graphql-tools (or any namespace of your choice), or only log when the DEBUG value is strictly 1 (and nothing else) as per the original PR.
I would expect the usage patterns of https://www.npmjs.com/package/debug, so it would only print when using DEBUG=* or DEBUG=graphql-tools.

Environment:

  • OS: MacOS
  • @graphql-tools/load: 7.8.0
  • NodeJS: 16.18.0
@falkenhawk
Copy link

also it breaks in our case

 - stderr: (node:15432) Warning: Label '@graphql-tools/load: collectSources' already exists for console.time()

@adrienharnay
Copy link

Hello, same here

(node:105) Warning: Label '@graphql-tools/load: collectSources' already exists for console.time()
(node:105) Warning: Label '@graphql-tools/load: useKindsFilter /drone/src/packages/util-shared/libs/apollo/clientSchema.gql' already exists for console.time()

I need DEBUG for other packages than this one. Has anyone found a workaround other than downgrading?

@ldiqual
Copy link
Contributor Author

ldiqual commented Dec 7, 2022

I made a change to use debug in graphql-tools/load, you can follow it here: #4886

@adrienharnay
Copy link

Nice, thank you!

@TwisterMc
Copy link

Is there a work around to turn off the debugging until the fix is released?

@real34
Copy link

real34 commented Oct 14, 2023

Has anyone found an alternative? This issue is almost 1 year old, and the Pull Request is left unmerged without any feedback from @ardatan.

Are there anything we could do to help getting this fix merged and released? It's not just one or two debug lines… we have a project with lots of .gql files, and every time we start it in DEBUG mode we have a wall of logs.

@benknight
Copy link

I had to delete DEBUG= in my .env file to resolve this

@ardatan
Copy link
Owner

ardatan commented Nov 23, 2023

Sorry for the late response!
Now the filters in the DEBUG environment variable is respected with this PR #5715
Let us know if you have any more issues.

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