Cannot set properties of undefined (setting '1') when running a UnityWebRequest

Hi,

We’ve found that if using Unity 2022 beta with BestHttp2 added to the project that any UnityWebRequest made will result in a type error in the browser. Tested on 2022.1.0b2 & 2022.1.0b10 and issue persists, on 2020 LTS problem does not appear.

We’ve gone ahead and created a bug ticket but would be great to know if anyone else has come across this and found a resolution.

Log excerpts:
Console:

Build 2.loader.js:70 exception thrown: TypeError: Cannot set properties of undefined (setting ‘1’),TypeError: Cannot set properties of undefined (setting ‘1’)
at _JS_WebRequest_Create (http://localhost:57156/Build/Build%202.framework.js:2799:40)

Framework.js

function _JS_WebRequest_Create(url, method) {
var _url = UTF8ToString(url);
var _method = UTF8ToString(method);
var abortController = new AbortController();
var requestOptions = {
url: _url,
init: {
method: _method,
signal: abortController.signal,
headers: {}
}
};
wr.abortControllers[wr.nextRequestId] = abortController; **Error here
wr.requests[wr.nextRequestId] = requestOptions;
return wr.nextRequestId++;
}

Same bug. Did u find any fix?

I got the same issue and also using BestHttp2. got any update?

Hi guys, I managed to fix the problem by changing the WebGL.framework.js file in the Build folder:
Replace this line:

var wr = { requestInstances: {}, nextRequestId: 1, loglevel: 2 };

with

var wr = { requestInstances: {}, nextRequestId: 1, loglevel: 2, responses:{}, timer:{}, requests:{}, abortControllers:{} };

I suggest unminifying the code to make it easier to read.
Hope this helps!

4 Likes

I am having the same bug with unity web requests as well as besthttp2…

Thanks a lot… you saved my day

Why can’t I find the file WebGL.framework.js, can you tell me where this file is?


My error is like this


I think this is it!
WebGL.framework.js is files has .jslib extension
It worked for me!
Thank smilefr

4 Likes

thank you!!! @smilefr and @potatosquadgames

Thank you ,your guys , you save me lots of time

Got the same error in 2021.3.9f1 - your solution fixed it for me. Thank you so much!
But hopefully unity is fixing this too anyway and this is not another workaround to remember for years now.

Hope you found out since then but if anyone else is having the same trouble… You need to build without compression. Otherwise, the file is embeded and you can’t read and modify it.

8590669--1151644--upload_2022-11-16_16-3-51.png

1 Like