Skip to content

Commit

Permalink
fix: Throw error when blob returns text content
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Oct 25, 2024
1 parent 591ff8e commit 507226d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ are doing mtv adjustments during precollision.

### Fixed

- Fixed issue where unexpected html HTML content from an image would silently hang the loader
- Fixed issue where Collision events ahd inconsistent targets, sometimes they were Colliders and sometimes they were Entities
- Fixed issue where `ex.Engine.screenshot()` images may not yet be loaded in time for use in `ex.Transition`s
- Fixed issue where there would be an incorrect background color for 1 frame when transitioning to a new scene
Expand Down
9 changes: 9 additions & 0 deletions src/engine/Resources/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ export class Resource<T> implements Loadable<T> {
return;
}

if (request.response instanceof Blob && request.response.type === 'text/html') {
const errorText = `Expected blob (usually image) data from the server when loading ${this.path}, but got HTML content instead!
Check your server configuration, for example Vite serves static files from the /public folder`;
this.events.emit('error', request.response);
reject(new Error(errorText));
return;
}

this.data = request.response;
this.events.emit('complete', this.data as any);
this.logger.debug('Completed loading resource', this.path);
Expand Down

0 comments on commit 507226d

Please sign in to comment.