Skip to content

Commit 2af70ce

Browse files
committed
fix: minimization issue with Next.js 15+
Starting with v15, minification cannot be customized using next.config.js. SWC that Next.js uses for minimization, inlines functions inside `XHRRequest` class, that results in losing `this` context and broken code
1 parent c1aa378 commit 2af70ce

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/platform/web/lib/http/request/xhrrequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class XHRRequest extends EventEmitter implements IXHRRequest {
183183
Logger.logAction(this.logger, Logger.LOG_ERROR, 'Request.on' + errorEvent.type + '()', errorMessage);
184184
this.complete(new PartialErrorInfo(errorMessage, code, statusCode));
185185
};
186-
xhr.onerror = function (errorEvent) {
186+
xhr.onerror = (errorEvent) => {
187187
errorHandler(errorEvent, 'XHR error occurred', null, 400);
188188
};
189189
xhr.onabort = (errorEvent) => {
@@ -193,7 +193,7 @@ class XHRRequest extends EventEmitter implements IXHRRequest {
193193
errorHandler(errorEvent, 'Request cancelled', null, 400);
194194
}
195195
};
196-
xhr.ontimeout = function (errorEvent) {
196+
xhr.ontimeout = (errorEvent) => {
197197
errorHandler(errorEvent, 'Request timed out', null, 408);
198198
};
199199

@@ -306,7 +306,7 @@ class XHRRequest extends EventEmitter implements IXHRRequest {
306306
});
307307
};
308308

309-
xhr.onreadystatechange = function () {
309+
xhr.onreadystatechange = () => {
310310
const readyState = xhr.readyState;
311311
if (readyState < 3) return;
312312
if (xhr.status !== 0) {

0 commit comments

Comments
 (0)