amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

MqttOverWS - Error handling message in node_modules/.vite/deps/@aws-amplify_pubsub.js

Open paulinesarana19 opened this issue 1 year ago • 4 comments

Before opening, please confirm:

JavaScript Framework

Not applicable

Amplify APIs

PubSub

Amplify Version

v6

Amplify Categories

notifications

Backend

Other

Environment information

# Put output below this line
System:
    OS: macOS 13.5.2
    CPU: (8) arm64 Apple M1
    Memory: 155.59 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm
    Watchman: 2023.10.09.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 125.1.66.115
    Chrome: 125.0.6422.142
    Safari: 16.6
  npmPackages:
    @aws-amplify/pubsub: ^6.1.8 => 6.1.8 
    @chromatic-com/storybook: ^1.4.0 => 1.4.0 
    @commitlint/cli: ^19.2.1 => 19.3.0 
    @commitlint/config-conventional: ^19.1.0 => 19.2.2 
    @googlemaps/js-api-loader: ^1.16.6 => 1.16.6 
    @googlemaps/markerclusterer: ^2.5.3 => 2.5.3 
    @iconify-json/svg-spinners: ^1.1.2 => 1.1.2 
    @iconify/tailwind: ^1.0.1 => 1.1.1 
    @material-tailwind/html: ^2.2.2 => 2.2.2 
    @playwright/test: ^1.28.1 => 1.44.0 
    @poppanator/sveltekit-svg: ^4.2.1 => 4.2.1 
    @storybook/addon-essentials: ^8.1.1 => 8.1.1 
    @storybook/addon-interactions: ^8.1.1 => 8.1.2 
    @storybook/addon-links: ^8.1.1 => 8.1.1 
    @storybook/blocks: ^8.1.1 => 8.1.1 
    @storybook/svelte: ^8.1.1 => 8.1.1 
    @storybook/sveltekit: ^8.1.1 => 8.1.1 
    @storybook/test: ^8.1.1 => 8.1.2 
    @sveltejs/adapter-node: ^5.0.1 => 5.0.1 
    @sveltejs/kit: ^2.0.0 => 2.5.9 
    @sveltejs/vite-plugin-svelte: ^3.0.2 => 3.1.0 
    @tadashi/svelte-editor-quill: ^2.2.0 => 2.2.0 
    @tiptap/core: ^2.4.0 => 2.4.0 
    @tiptap/extension-blockquote: ^2.4.0 => 2.4.0 
    @tiptap/extension-bold: ^2.4.0 => 2.4.0 
    @tiptap/extension-bullet-list: ^2.4.0 => 2.4.0 
    @tiptap/extension-link: ^2.4.0 => 2.4.0 
    @tiptap/extension-ordered-list: ^2.4.0 => 2.4.0 
    @tiptap/extension-paragraph: ^2.4.0 => 2.4.0 
    @tiptap/extension-placeholder: ^2.4.0 => 2.4.0 
    @tiptap/extension-underline: ^2.4.0 => 2.4.0 
    @tiptap/pm: ^2.4.0 => 2.4.0 
    @tiptap/starter-kit: ^2.4.0 => 2.4.0 
    @types/amplify: ^1.1.28 => 1.1.28 
    @types/crypto-js: ^4.2.2 => 4.2.2 
    @types/eslint: ^8.56.0 => 8.56.10 
    @types/google.maps: ^3.55.7 => 3.55.9 
    @types/google.visualization: ^0.0.74 => 0.0.74 
    @types/js-cookie: ^3.0.6 => 3.0.6 
    @types/lodash: ^4.17.0 => 4.17.4 
    @types/validator: ^13.11.9 => 13.11.10 
    @typescript-eslint/eslint-plugin: ^7.0.0 => 7.9.0 
    @typescript-eslint/parser: ^7.0.0 => 7.9.0 
    autoprefixer: ^10.4.19 => 10.4.19 
    aws-amplify: ^6.3.4 => 6.3.5 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    crypto-js: ^4.2.0 => 4.2.0 
    date-fns: ^3.6.0 => 3.6.0 
    date-fns-tz: ^3.1.3 => 3.1.3 
    dotenv: ^16.4.5 => 16.4.5 
    eslint: ^8.56.0 => 8.57.0 (8.4.1)
    eslint-config-prettier: ^9.1.0 => 9.1.0 
    eslint-plugin-storybook: ^0.8.0 => 0.8.0 
    eslint-plugin-svelte: ^2.35.1 => 2.39.0 
    husky: ^9.0.11 => 9.0.11 
    js-cookie: ^3.0.5 => 3.0.5 
    libphonenumber-js: ^1.10.60 => 1.11.1 
    libphonenumber-js/build:  undefined ()
    libphonenumber-js/core:  undefined ()
    libphonenumber-js/max:  undefined ()
    libphonenumber-js/max/metadata:  undefined ()
    libphonenumber-js/min:  undefined ()
    libphonenumber-js/min/metadata:  undefined ()
    libphonenumber-js/mobile:  undefined ()
    libphonenumber-js/mobile/examples:  undefined ()
    libphonenumber-js/mobile/metadata:  undefined ()
    lint-staged: ^15.2.2 => 15.2.2 
    lodash: ^4.17.21 => 4.17.21 
    patch-package: ^8.0.0 => 8.0.0 
    pluralize: ^8.0.0 => 8.0.0 
    postcss: ^8.4.38 => 8.4.38 
    prettier: ^3.1.1 => 3.2.5 
    prettier-plugin-svelte: ^3.1.2 => 3.2.3 
    prettier-plugin-tailwindcss: ^0.5.12 => 0.5.14 
    rimraf: ^5.0.7 => 5.0.7 (3.0.2, 2.7.1, 2.6.3)
    storybook: ^8.1.1 => 8.1.1 
    svelte: ^4.2.7 => 4.2.17 
    svelte-autosize: ^1.1.0 => 1.1.0 
    svelte-check: ^3.6.0 => 3.7.1 
    svelte-file-dropzone: ^2.0.7 => 2.0.7 
    svelte-grid: ^5.1.2 => 5.1.2 
    svelte-select: ^5.8.3 => 5.8.3 
    tailwindcss: ^3.4.1 => 3.4.3 
    tslib: ^2.4.1 => 2.6.2 (1.14.1)
    typescript: ^5.0.0 => 5.4.5 
    uuid: ^9.0.1 => 9.0.1 
    validator: ^13.11.0 => 13.12.0 
    vite: ^5.0.3 => 5.2.11 
    vitest: ^1.2.0 => 1.6.0 
  npmGlobalPackages:
    corepack: 0.17.0
    netlify-cli: 17.10.1
    npm: 8.19.4

Describe the bug

When receiving messages on a subscribed PubSub topic, an error warning is thrown filter2.split is not a function at mqttTopicMatch.... image This hasn't happened before with the same setup. boto3 is used to publish a message. Svelte is used as web framework.

Expected behavior

There should be no issue even when a basic dictionary is published as a message.

Reproduction steps

  1. Following this setup for subscribing a topic https://docs.amplify.aws/gen1/javascript/build-a-backend/more-features/pubsub/subscribe/.
  2. A message is published using boto3('iot-data').
  3. Error warning is triggered on message received on Svelte.

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

import { env } from '$env/dynamic/public';

export default { aws_project_region: AWS_PROJECT_REGION, aws_cognito_identity_pool_id: AWS_COGNITO_IDENTITY_POOL_ID, aws_cognito_region: AWS_COGNITO_REGION, aws_user_pools_id: AWS_USER_POOLS_ID, aws_user_pools_web_client_id: AWS_USER_POOLS_WEB_CLIENT_ID, oauth: {}, aws_cognito_username_attributes: ['EMAIL'], aws_cognito_social_providers: [], aws_cognito_signup_attributes: ['EMAIL'], aws_cognito_mfa_configuration: 'OFF', aws_cognito_mfa_types: ['SMS'], aws_cognito_password_protection_settings: { passwordPolicyMinLength: 8, passwordPolicyCharacters: [] }, aws_cognito_verification_mechanisms: ['EMAIL'] };

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

paulinesarana19 avatar Jun 05 '24 04:06 paulinesarana19

same on my end using the version below

"@aws-amplify/pubsub": "^6.1.8"
"aws-amplify": "^6.3.4",

rjuevesano avatar Jun 05 '24 05:06 rjuevesano

Hey, @paulinesarana19 👋. Can you share a code snippet where you're using the mqttTopicMatch? Working on reproducing this on a Gen 1 app using v6 of Amplify.

CC: @rjuevesano

cwomack avatar Jun 05 '24 18:06 cwomack

Hey, @paulinesarana19 👋. Can you share a code snippet where you're using the mqttTopicMatch? Working on reproducing this on a Gen 1 app using v6 of Amplify.

CC: @rjuevesano

I'm using svelte and here's my code snippet.

$lib/pubsub.ts

import { PubSub } from '@aws-amplify/pubsub';
export const pubsub = new PubSub({...});

+layout.svelte

import { pubsub } from '$lib/pubsub';

onMount(() => {
		pubsub
			.subscribe({
				topics: [topics]
			})
			.subscribe({
				next: (message) => {
					console.log('[Incoming]', message);
				},
				error: (error) => console.error(error),
				complete: () => console.log('Done')
			})
	}
)

Calling PubSub directly without creating a separate export function won't return a warning/error and it's working properly.

+layout.svelte

onMount(() => {
		new PubSub({...})
			.subscribe({
				topics: [topics]
			})
			.subscribe({
				next: (message) => {
					console.log('[Incoming]', message);
				},
				error: (error) => console.error(error),
				complete: () => console.log('Done')
			})
	}
)

rjuevesano avatar Jun 05 '24 23:06 rjuevesano

I've been trying to reproduce this to no avail but have been trying to dig into the dependencies and compatibility on v6 based on OP's environment information. @rjuevesano, can you share your package.json as well as any configuration details for how you've implemented PubSub? Can you also clarify what the message format is (I'm it's assuming JSON) that you're publishing as well as the size (again, assuming small/minimal but want to be sure)?

cwomack avatar Oct 08 '24 15:10 cwomack

Closing this issue as we have not heard back from you. If you are still experiencing this, please feel free to reply back and provide any information previously requested and we'd be happy to re-open the issue.

Thank you!

cwomack avatar Oct 29 '24 21:10 cwomack