fix: fix web-worker
related issues
#140
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request introduces significant improvements to the browser package, focusing on enhanced web worker integration, error handling, and configuration flexibility. The main changes include switching to an inline web worker build approach, improving error serialization and propagation between threads, and adding support for configurable storage mechanisms. These updates help modernize the codebase, improve reliability, and make the authentication client more adaptable for different environments.
Web Worker Integration & Build System:
esbuild-plugin-inline-worker
for bundling web workers, updating the build configuration inesbuild.config.mjs
and adding the dependency topackage.json
. This allows the worker code to be bundled inline and ensures proper polyfills for browser environments. [1] [2] [3]worker.ts
toweb.worker.ts
and added polyfills forBuffer
andglobal
to ensure compatibility in browser worker contexts.web.worker.ts
and enabled dynamic worker instantiation. [1] [2] [3] [4]Error Handling Improvements:
MessageUtils
to robustly handleError
objects, non-Error objects, and primitives, ensuring errors are reliably transferred between main thread and worker.web-worker-client.ts
by parsing errors safely and wrapping unknown or malformed errors in a customAsgardeoAuthException
. [1] [2] [3]Configuration Flexibility:
AsgardeoBrowserConfig
type to support multiple storage options, includingsessionStorage
,localStorage
,browserMemory
, andwebWorker
. [1] [2]Related Issues
@asgardeo/react
&@asgardeo/nextjs
#81Related PRs
Checklist
Security checks