libnyanpasu/clash-nyanpasu · warning
Proxy addEventListener:
Error message
Proxy addEventListener:
What it means
The bootstrap script in index.html wraps a global object's addEventListener to intercept 'change' listeners. If addEventListener is called with fewer than 2 arguments or with an event name other than 'change', it logs console.error('Cannot proxy addEventListener:', arguments) and refuses to register the listener. If called with more than 2 arguments but event 'change', it logs console.warn('Proxy addEventListener:', arguments) and registers via addListener.
Source
Thrown at frontend/nyanpasu/index.html:25
href="./assets/image/logo.ico"
type="image/x-icon"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%- title %></title>
<%- injectScript %>
<script>
;(function () {
var _matchMedia = window.matchMedia
window.matchMedia = function () {
var v = _matchMedia.apply(null, arguments)
if (!v.addEventListener) {
v.addEventListener = function () {
if (arguments.length < 2 || arguments[0] !== 'change') {
console.error('Cannot proxy addEventListener:', arguments)
return
}
if (arguments.length > 2) {
console.warn('Proxy addEventListener:', arguments)
}
v.addListener(arguments[1])
}
}
return v
}
})()
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
View on GitHub (pinned to f7dbce2997)
Solutions
- Check the logged `arguments` to see which event name and how many arguments were passed.
- If the code registers a non-'change' event on this object, that's unsupported — rework the script to attach other events to the proper target (document/window) instead of this proxied object.
- If it's a legitimate 'change' listener with a third options argument, use addListener(handler) directly or pass only (event, handler) to silence the warn.
- If you control the wrapper and new event support is needed, extend the proxy to forward additional event types instead of erroring.
Example fix
// before (third argument triggers the proxy warning)
v.addEventListener('change', handler, { passive: true });
// after
v.addEventListener('change', handler);
// or
v.addListener(handler); Defensive patterns
Strategy: fallback
Validate before calling
if (typeof v.addEventListener === 'function' && arguments.length >= 2 && arguments[0] === 'change') {
v.addEventListener('change', arguments[1]);
} else {
v.addListener(arguments[1]);
} Type guard
function supportsAddEventListener(v: unknown): v is { addEventListener(type: 'change', fn: () => void): void } {
return typeof v === 'object' && v !== null &&
typeof (v as any).addEventListener === 'function';
} Prevention
- On this proxied object, call addEventListener only as (type: 'change', handler) with exactly two arguments.
- Attach non-'change' events to the proper DOM target (document/window), not the proxied global.
- Use addListener(handler) directly for change listeners to bypass the proxy checks.
- Pin/audit dependency upgrades that might add new addEventListener calls on the proxied object.
When it happens
Trigger: Any script (or webview-injected code) calling that proxied object's addEventListener with an event type other than 'change' (or with missing handler argument) — e.g. document/element-style code doing el.addEventListener('click', fn) on the proxied global, or a library adding a change listener with extra options (capture/useCapture third argument).
Common situations: A vendored library or user script assumes standard DOM addEventListener semantics (any event name, optional options object) but the proxied object only supports a single 'change' event; upgrade of a dependency introduces new addEventListener calls for other events.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- failed to get tray menu window
- failed to get tray menu window after creation
- Function is locked: ${fnRef.current.name}
- [mutation-degradation]
AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08).
Data as JSON: /api/errors/cb41ed1483d5c402.
Report an issue: GitHub.