@upstash/redis import in file causing module to be imported dynamically
See original GitHub issueThis is an issue as of 1.3.2-alpha.0
- fine for 1.3.0 (the version we’ve now pinned our application to).
Platform: Next.js 12.0.7
We have a very simple file (redis.ts
):
import { Redis } from "@upstash/redis";
const redis = Redis.fromEnv();
export default redis;
We then import this in another file (import redis from "./redis";
) - The redis
object is now a promise that needs to be awaited before we can access the exported properties. This is leading us to believe that Next is interpreting something upstream as needing to be dynamically imported.
Issue Analytics
- State:
- Created a year ago
- Comments:17
Top Results From Across the Web
How to Dynamically Import ECMAScript Modules
The imported module — the one which exports export const func = () => {} and is being imported. The importing module uses...
Read more >Issues · upstash/upstash-redis - GitHub
3. @upstash/redis import in file causing module to be imported dynamically. #109 opened on Jun 13 by cathykc · @chronark.
Read more >ES2020: `import()` – dynamically importing ES modules - 2ality
The proposal enables dynamic module imports #. The proposed operator for loading modules dynamically works as follows: const moduleSpecifier = ' ...
Read more >Dynamic Module Imports - Web Dev Simplified Blog
By using dynamic module imports you can speed up your applications ... JavaScript across multiple files and import them only when needed.
Read more >How to use Dynamic Imports for Modules - JavaScript Tutorial
In today's video I'll be showing you how to use Dynamic Imports for your modules in JavaScript - this allows you to dynamically...
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 FreeTop 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
Top GitHub Comments
Hey @cathykc, thank you for reporting this.
We recently found something similar in nextjs I believe. For some reason it didn’t load environment variables properly, when creating such a utility
redis.ts
file. The fix was to just not do that and create a newRedis.fromEnv()
instance instead of importing from the utility file, which doesn’t cause any issues, as the sdk is completely stateless.However it’s not a perfect solution either. I will dig some more.
In the meantime, can you try upgrading to
v1.6.0
and see if this behavior still exists?thank you so much. I’ll check it out