P2d: Function.prototype.bind + Function Proxy Konflikt (Discord/webpack) #77

Closed
opened 2026-06-18 17:17:55 +00:00 by Artur · 1 comment
Owner

P2d: Function.prototype.bind + Function Proxy Konflikt

Priority: HIGH
Betrifft: discord.com/app (webpack Chunks)
Fehler: TypeError: |this| is not a function inside Function.prototype.bind

Problembeschreibung

Discord's webpack internals nutzen Function.prototype.bind.call(fn, null) oder
Function.prototype.apply.call(fn, null, args). Unser Function-Proxy aus Sprint 14
interceptet das, aber die via eval() erzeugte Funktion (in _realmMakeFunction)
ist keine echte Function-Instanz mehr — .bind() scheitert.

Aktueller Ablauf:

  1. Discord-Code: Function.prototype.bind.call(someFactory, null)
  2. _win.Function = unser Proxy
  3. Proxy.apply-Trap feuert → eval() erzeugt Funktion
  4. fn.bind(_win) im construct-Trap returned gebundene Funktion
  5. Discord ruft .bind() auf dieser Funktion auf → TypeError

Option A: Echte Function-Instanz statt eval() (EMPFEHLUNG)

function _realmMakeFunction(args) {
  var body = args.length > 0 ? args[args.length - 1] : "";
  var params = args.length > 1
    ? Array.prototype.slice.call(args, 0, -1).join(", ")
    : "";
  try {
    // new Function() innerhalb des eval()-Scopes erzeugt echte Function
    return new Function(params, body);
  } catch(e) {
    return function() {};
  }
}

Akzeptanzkriterien

  • Discord's webpack lädt ohne |this| is not a function Error
  • Function.prototype.bind.call(fn, null) funktioniert
  • fn.apply(null, args) funktioniert
  • Bestehende new Function()-Tests aus Sprint 14 passieren weiterhin
  • Unit-Test: Function.bind mit Proxy-Interception

Betroffene Dateien

Datei Änderung
src/js/execution-realm.ts _realmMakeFunction — echte Function statt eval()
tests/unit/sprint14-new-function-sandbox.test.ts Neue Tests ergänzen
## P2d: `Function.prototype.bind` + Function Proxy Konflikt **Priority:** HIGH **Betrifft:** discord.com/app (webpack Chunks) **Fehler:** `TypeError: |this| is not a function inside Function.prototype.bind` ### Problembeschreibung Discord's webpack internals nutzen `Function.prototype.bind.call(fn, null)` oder `Function.prototype.apply.call(fn, null, args)`. Unser Function-Proxy aus Sprint 14 interceptet das, aber die via `eval()` erzeugte Funktion (in `_realmMakeFunction`) ist keine echte Function-Instanz mehr — `.bind()` scheitert. **Aktueller Ablauf:** 1. Discord-Code: `Function.prototype.bind.call(someFactory, null)` 2. `_win.Function` = unser Proxy 3. Proxy.apply-Trap feuert → eval() erzeugt Funktion 4. `fn.bind(_win)` im construct-Trap returned gebundene Funktion 5. Discord ruft `.bind()` auf dieser Funktion auf → TypeError ### Option A: Echte Function-Instanz statt eval() (EMPFEHLUNG) ```typescript function _realmMakeFunction(args) { var body = args.length > 0 ? args[args.length - 1] : ""; var params = args.length > 1 ? Array.prototype.slice.call(args, 0, -1).join(", ") : ""; try { // new Function() innerhalb des eval()-Scopes erzeugt echte Function return new Function(params, body); } catch(e) { return function() {}; } } ``` ### Akzeptanzkriterien - [ ] Discord's webpack lädt ohne `|this| is not a function` Error - [ ] `Function.prototype.bind.call(fn, null)` funktioniert - [ ] `fn.apply(null, args)` funktioniert - [ ] Bestehende new Function()-Tests aus Sprint 14 passieren weiterhin - [ ] Unit-Test: Function.bind mit Proxy-Interception ### Betroffene Dateien | Datei | Änderung | |-------|----------| | `src/js/execution-realm.ts` | _realmMakeFunction — echte Function statt eval() | | `tests/unit/sprint14-new-function-sandbox.test.ts` | Neue Tests ergänzen |
Artur closed this issue 2026-06-18 17:27:08 +00:00
Author
Owner

⚠️ Kein separater Fix nötig — Symptom von anderen Issues

Nach Analyse: TypeError: |this| is not a function inside Function.prototype.bind wird verursacht durch:

  1. Webpack-Chunk-Fetch liefert HTML (404/Error-Seite) → #76 HTML-as-JS Filter adressiert das
  2. ES Module relative Imports fehlschlagen → #74 adressiert NameTooLong, relative Imports brauchen separaten Fix

Der Function-Proxy aus Sprint 14 ist korrekt. Der Fehler entsteht weil webpack undefined/Proxy-Werte
bekommt, wenn Module nicht geladen werden können, und .bind() darauf aufruft.

Status: Geschlossen — keine Änderung am Function Proxy nötig

⚠️ **Kein separater Fix nötig** — Symptom von anderen Issues Nach Analyse: `TypeError: |this| is not a function inside Function.prototype.bind` wird verursacht durch: 1. Webpack-Chunk-Fetch liefert HTML (404/Error-Seite) → #76 HTML-as-JS Filter adressiert das 2. ES Module relative Imports fehlschlagen → #74 adressiert NameTooLong, relative Imports brauchen separaten Fix Der Function-Proxy aus Sprint 14 ist korrekt. Der Fehler entsteht weil webpack undefined/Proxy-Werte bekommt, wenn Module nicht geladen werden können, und `.bind()` darauf aufruft. **Status:** Geschlossen — keine Änderung am Function Proxy nötig
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
glow-all/true-headless-browser#77
No description provided.