Skip to content

Conversation

@ColaFanta
Copy link
Contributor

The default export of debug package is now as a function instead of a class.
https://github.com/debug-js/debug/blob/6b2c5fbdb7d414483d9e306ef234acb4cd7ea67c/src/common.js#L7

Use debug as class works most of the time but may cause error under some strict environment. This PR fixes this by changing the use of debug from class to function.

@panva
Copy link
Owner

panva commented Oct 15, 2025

may cause error under some strict environment

Can you please be specific?

@ColaFanta ColaFanta force-pushed the hotfix/fix-debug-use branch from ad3967f to 5ea8b07 Compare October 15, 2025 13:57
@ColaFanta
Copy link
Contributor Author

I am using node-oidc-provider on Cloudflare Workers and have successfully adapted this library to the Workers WebAPI environment. However, I still encounter the following error, which this PR fixes:

TypeError: Debug is not a constructor  
(file:///.../lib/shared/error_handler.js:10:14)  

The reason behind this error may be due to using Debug as a constructor. In lib/shared/error_handler.js, the usage is as follows:

//...  
import Debug from 'debug'  
//...  
const debug = new Debug('oidc-provider:error')  

Meanwhile, in the source code of the debug npm package, the default export is defined like this:

function setup(env) {  
	createDebug.debug = createDebug;  
	createDebug.default = createDebug;  
	createDebug.coerce = coerce;  
	createDebug.disable = disable;  
	...  
	return createDebug;  
}  

module.exports = setup;  

I am currently applying this patch in my project and everything works fine, so I hope this change can be merged into the official repo.

@panva
Copy link
Owner

panva commented Oct 15, 2025

@ColaFanta I'm not opposed to adjusting the usage of debug but you need to first report this discrepency in https://github.com/cloudflare/workerd.

@panva
Copy link
Owner

panva commented Oct 15, 2025

And FWIW the only supported oidc-provider runtime is Node.js

@panva panva merged commit b86b47c into panva:main Oct 16, 2025
44 checks passed
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

Successfully merging this pull request may close these issues.

2 participants