Skip to content

"not a constructor" error when initialising WebPubSubClient using Vite #27980

Open

Description

  • Package Name: @azure/web-pubsub-client
  • Package Version: ^1.0.0-beta.3
  • Operating system: Windows
  • nodejs
    • version: v21.1.0
  • browser
    • name/version: Google Chrome/119.0.6045.200
  • typescript
    • version: ^5.0.0

Describe the bug
Can't initialise a new WebPubSubClient instance in my Sveltekit project. I'm getting the error TypeError: import_events.default is not a constructor (see screenshot to show where)

To Reproduce
Steps to reproduce the behavior:

  1. Create a new skeleton Sveltekit project with Typescript: npm create svelte@latest bug-test
  2. Add the following code to the +page.svelte file
    <script lang="ts">
    import { WebPubSubClient } from '@azure/web-pubsub-client';
    
    let tokenUrl = "<add token url>";
    let client: WebPubSubClient;
    
    async function connect() {
    	client = new WebPubSubClient(tokenUrl);
    	await client.start();
    
    	client.on('connected', () => console.log('Web PubSub Connected'));
    	client.on('group-message', m => console.log('Message received: %s', JSON.stringify(m)));
    }
    </script>
    
    <button on:click={connect}>Connect</button>
    
  3. Run the server and click the button

Expected behavior
The client should be initialised so I can connect to the Web PubSub

Screenshots
image

Additional context
I'm not a frontend developer in any way, but I'll try my best to give as much info as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.WebPubSubbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions