[Typescript] Error: No pubsub module applied for subscription when attempting to create subscription.
See original GitHub issueBefore opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
Vue
Amplify APIs
GraphQL API
Amplify Categories
auth, api
Environment information
# Put output below this line
System:
OS: Windows 10 10.0.22000
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Memory: 116.57 GB / 127.90 GB
Binaries:
Node: 16.15.0 - E:\x64\nodejs\node.EXE
npm: 8.18.0 - E:\x64\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (104.0.1293.70)
Internet Explorer: 11.0.22000.120
npmPackages:
@aws-amplify/ui-vue: ^2.4.19 => 2.4.19
@popperjs/core: ^2.11.6 => 2.11.6
@rushstack/eslint-patch: ^1.1.4 => 1.1.4
@types/node: ^16.11.47 => 16.11.56
@vitejs/plugin-vue: ^3.0.1 => 3.0.3
@vue/eslint-config-prettier: ^7.0.0 => 7.0.0
@vue/eslint-config-typescript: ^11.0.0 => 11.0.0
@vue/tsconfig: ^0.1.3 => 0.1.3
aws-amplify: ^4.3.34 => 4.3.34
bootstrap: ^5.2.0 => 5.2.0
bootswatch: ^5.2.0 => 5.2.0
eslint: ^8.21.0 => 8.23.0
eslint-plugin-vue: ^9.3.0 => 9.4.0
npm-run-all: ^4.1.5 => 4.1.5
pinia: ^2.0.17 => 2.0.21
prettier: ^2.7.1 => 2.7.1
typescript: ~4.7.4 => 4.7.4
vite: ^3.0.4 => 3.0.9
vite-plugin-checker: ^0.5.0 => 0.5.0
vue: ^3.2.37 => 3.2.38
vue-router: ^4.1.3 => 4.1.5
vue-tsc: ^0.39.5 => 0.39.5
npmGlobalPackages:
@angular/cli: 14.2.1
@aws-amplify/cli: 9.2.1
npm: 8.18.0
Describe the bug
When attempting to create a subscription, the error: Error: No pubsub module applied for subscription
is thrown.
I believe this has something to do with line 29 of GraphQLAPI.ts: import PubSub from '@aws-amplify/pubsub';
not working correctly.
When puttingimport PubSub from '@aws-amplify/pubsub';
into my main.ts
the app no longer starts, giving the error: TypeError: Object.setPrototypeOf: expected an object or null, got undefined
.
Expected behavior
The subscription is created with no issue.
Reproduction steps
Install any version of aws-amplify after 4.3.31. Start the app Attempt to create a subscription
Code Snippet
// Put your code below this line.
function createSubscribe() {
API.graphql(graphqlOperation(onCreateX)) as Observable<any>;
}
Log output
// Put your logs below this line
Error: No pubsub module applied for subscription
aws-exports.js
const awsmobile = {
"aws_project_region": "us-east-2",
"aws_cognito_identity_pool_id": "us-east-2:7d085aec-f2b1-4b27-970e-xxx",
"aws_cognito_region": "us-east-2",
"aws_user_pools_id": "us-east-2_xxx",
"aws_user_pools_web_client_id": "xxx",
"oauth": {},
"aws_cognito_username_attributes": [],
"aws_cognito_social_providers": [],
"aws_cognito_signup_attributes": [],
"aws_cognito_mfa_configuration": "OPTIONAL",
"aws_cognito_mfa_types": [
"TOTP"
],
"aws_cognito_password_protection_settings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": [
"REQUIRES_LOWERCASE",
"REQUIRES_NUMBERS",
"REQUIRES_SYMBOLS",
"REQUIRES_UPPERCASE"
]
},
"aws_cognito_verification_mechanisms": [
"EMAIL"
],
"aws_appsync_graphqlEndpoint": "https://xxx.appsync-api.us-east-2.amazonaws.com/graphql",
"aws_appsync_region": "us-east-2",
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
"aws_user_files_s3_bucket": "xxx",
"aws_user_files_s3_bucket_region": "us-east-2"
};
export default awsmobile;
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
Downgrading to 4.3.31 fixes this issue.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Amplify No pubsub module applied for subscription ReactJs
I am facing issue with subscriptions its throw exception
Read more >Subscriptions in Apollo Server - Apollo GraphQL Docs
The PubSub class is not recommended for production environments, because it's an in-memory event system that only supports a single server instance. After...
Read more >Issues · aws-amplify/amplify-js · GitHub
[Typescript] Error: No pubsub module applied for subscription when attempting to create subscription. GraphQL Related to GraphQL API issues pending-triage ...
Read more >PubSub - Subscribe & Unsubscribe - JavaScript - Amplify Docs
Learn more about how to subscribe to and unsubscribe from topics using Amplify's PubSub category ... error, Triggered when subscription attempt fails.
Read more >@aws-amplify/pubsub | Yarn - Package Manager
If you are using exported paths within your Amplify JS application, (e.g. import from "@aws-amplify/analytics/lib/Analytics" ) this will now break and no longer ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have also verified and it seems that the issue is fixed. I’ll open another issue in case it’s not after more extensive tests.
Verified against my local codebase and things are golden. Thank you!