Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm doesn't resolve class imports #15897

Closed
mpodwysocki opened this issue Sep 13, 2022 · 4 comments
Closed

npm doesn't resolve class imports #15897

mpodwysocki opened this issue Sep 13, 2022 · 4 comments
Labels
bug Something isn't working correctly node compat

Comments

@mpodwysocki
Copy link

Using Azure Notification Hubs, when importing, @azure/notification-hubs, I cannot resolve a class that extends the ServiceClient class from import @azure/core-client. I get the following error which means it cannot resolve the ServiceClient class. Can confirm that this works using Node with this nhtest sample

error: Uncaught TypeError: Class extends value does not have valid prototype property undefined
    at file:///Users/<redacted>/Library/Caches/deno/npm/registry.npmjs.org/@azure/notification-hubs/1.0.0-beta.4/dist-esm/src/client/index.js:18:45

Line 18 has the following code from the index.js file:

class NotificationHubsServiceClient extends ServiceClient {

And ServiceClient is imported from the following:

import { ServiceClient } from "@azure/core-client";

Full reproduction below of a sample program to send a message using Azure Notification Hubs.

import * as process from "https://deno.land/std@0.155.0/node/process.ts";
import { createClientContext } from "npm:@azure/notification-hubs@1.0.0-beta.4/client";
import { createAppleNotification } from "npm:@azure/notification-hubs@1.0.0-beta.4/models/notification";
import { sendDirectNotification } from "npm:@azure/notification-hubs@1.0.0-beta.4/client/sendDirectNotification";

// Define connection string and hub name
const connectionString = process.env.NOTIFICATIONHUBS_CONNECTION_STRING || "<connection string>";
const hubName = process.env.NOTIFICATION_HUB_NAME || "<hub name>";

// Define message constants
const DUMMY_DEVICE = "00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0";
const deviceToken = process.env.APNS_DEVICE_TOKEN || DUMMY_DEVICE;

const context = createClientContext(connectionString, hubName);

const messageBody = `{ "aps" : { "alert" : { title: "Hello", body: "Hello there SDK Review!" } } }`;

const notification = createAppleNotification({
  body: messageBody,
  headers: {
    "apns-priority": "10",
    "apns-push-type": "alert",
  },
});

// Not required but can set test send to true for debugging purposes.
const result = await sendDirectNotification(context, deviceToken, notification);

console.log(`Direct send Tracking ID: ${result.trackingId}`);
console.log(`Direct send Correlation ID: ${result.correlationId}`);
console.log(`Results: ${JSON.stringify(result, null, 2)}`);
@ry ry added bug Something isn't working correctly node compat labels Sep 13, 2022
@bartlomieju
Copy link
Member

I just tried the reproduction with the latest canary build and I get this error:

error: Uncaught Error: Connection string malformed: each part of the connection string must have an `=` assignment.
    at parseConnectionString (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/@azure/notification-hubs/1.0.0-beta.4/dist-esm/src/auth/connectionStringUtils.js:29:19)
    at parseNotificationHubsConnectionString (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/@azure/notification-hubs/1.0.0-beta.4/dist-esm/src/auth/connectionStringUtils.js:56:26)
    at new NotificationHubsServiceClient (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/@azure/notification-hubs/1.0.0-beta.4/dist-esm/src/client/index.js:28:34)
    at createClientContext (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/@azure/notification-hubs/1.0.0-beta.4/dist-esm/src/client/index.js:16:12)
    at file:///Users/ib/dev/deno/foo.js:14:17

which I believe is just a problem with missing configuration.

I think this problem was fixed in #15837 and will be released in v1.25.3 later this week. I'm gonna go ahead and close this issue for now.

@mpodwysocki
Copy link
Author

@bartlomieju yes, that's the issue. Thanks!

@mpodwysocki
Copy link
Author

@bartlomieju The only blocker then to getting Notification Hubs working at this point is the crypto implementation denoland/std#2557

@bartlomieju
Copy link
Member

@mpodwysocki thanks for the info, it looks like there's already a PR open for that missing implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

No branches or pull requests

3 participants