Can't create getstream (feeds) client. undefined reading connect - getstream-io

I'm trying to create a feeds client to execute methods like upload image. I'm running this from a ReactJS/Javascript client. I'm using TypeScript. When I try to execute my code, I get the following error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'connect')
at handleImage (CommentField.tsx:137:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
at invokeGuardedCallback (react-dom.development.js:4277:1)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:1)
at executeDispatch (react-dom.development.js:9041:1)
at processDispatchQueueItemsInOrder (react-dom.development.js:9073:1)
at processDispatchQueue (react-dom.development.js:9086:1)
at dispatchEventsForPlugins (react-dom.development.js:9097:1)
at react-dom.development.js:9288:1
The code is this:
const client = stream.connect("<apiKey>", streamToken, "<appId>")
const imageUploadResponse = await client.images.upload(e.target.files[0])
console.log("IMAGE RESPONSE: ", imageUploadResponse)
Am I doing something wrong in my code? Or is this just broken? If it's broken, is there an older rev that works?

Related

TypeError: TextEncoder is not a constructor

I was trying to run tests using supertest in nodejs and I got this error message
ReferenceError: TextEncoder is not defined
Then i was advised to locate the file "node_modules/whatwg-url/lib/encoding.js" and add this lines of code at the top
const { TextEncoder, TextDecoder } = require("./utils");
After i did that, i started getting this message
TypeError: TextEncoder is not a constructor
please, i am using node version 17.4.0

Why is Fetch Undefined?

I am copying a code DIRECTLY from discord.js guide to send a direct message to myself (and only myself) through my bot.
module.exports = {
callback: async(client) => {
const user = await client.users.fetch('503965897203908609');
user.send('content');
}
}
here's the relevant code. and when I run the command, I get
TypeError: Cannot read properties of undefined (reading 'fetch')
WHY
Because your client.users is undefined, if we try to access a property on undefined it will throw an error.
as to why client.users is undefined, that would be something which requires more code to look at

Shopify React Next Cannot read property "/_app" of undefined

I am trying to setup an environment to develop a shopify theme, and I followed the tutorial found here:
https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/build-your-user-interface-with-polaris
But when I connected my server, the app, the store and so on, when I started integrating polaris, on build I started getting errors.
First I had an error about a missing module build-manifest.json and I found a suggestion somewhere on the forums to make a blank file with just {} in it in the .next/ directory and so I did.
Then it complained about react-loadable-manifest.json missing, and I did the same for it.
Both of these errors were being thrown from this piece of code:
server.use(async (ctx) => {
await handle(ctx.req, ctx.res); // <-- this line
ctx.respond = false;
ctx.res.statusCode = 200;
return;
});
And now I have the following errors:
error - ./node_modules/#shopify/polaris/dist/styles.css
TypeError: Cannot read property 'tapAsync' of undefined
TypeError: Cannot read property '/_app' of undefined
Thats the full stack, I dont see any "custom" code related to it:
error - ./node_modules/#shopify/polaris/dist/styles.css
TypeError: Cannot read property 'tapAsync' of undefined
TypeError: Cannot read property '/_app' of undefined
at getPageFiles (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\get-page-files.js:1:311)
at getDocumentFiles (C:\Users\Darkbound\Desktop\shopifyreact\server\.next\server\pages\_document.js:266:54)
at Head.render (C:\Users\Darkbound\Desktop\shopifyreact\server\.next\server\pages\_document.js:589:19)
at processChild (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\react-dom\cjs\react-dom-server.node.development.js:3450:18)
at resolve (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\react-dom\cjs\react-dom-server.node.development.js:3270:5)
at ReactDOMServerRenderer.render (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\react-dom\cjs\react-dom-server.node.development.js:3753:22)
at ReactDOMServerRenderer.read (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\react-dom\cjs\react-dom-server.node.development.js:3690:29)
at renderToStaticMarkup (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\react-dom\cjs\react-dom-server.node.development.js:4314:27)
at renderDocument (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\render.js:3:715)
at renderToHTML (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\render.js:56:103)
at async C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\next-server.js:107:97
at async C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\next-server.js:100:142
at async DevServer.renderToHTMLWithComponents (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\next-server.js:132:387)
at async DevServer.renderErrorToHTML (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\next-server.js:134:327)
at async DevServer.render (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\next-server.js:72:236)
at async Object.fn (C:\Users\Darkbound\Desktop\shopifyreact\server\node_modules\next\dist\next-server\server\next-server.js:56:580)
I came across this issue when jumping next multiple dependencies versions at once. I was able to resolve it by removing the wrapped Container
https://github.com/vercel/next.js/blob/master/errors/app-container-deprecated.md

GridFSBucketReadStream error: cannot read property 'write' of null

I'm using mongodb module to download a file from gridfs.
Here's the code -
import { Db, Server, GridFSBucket } from 'mongodb';
let gfs = new GridFSBucket(new Db(<db_name>, new Server("127.0.0.1", 27017)), {"bucketName": "fs"});
let readStreamData = gfs.openDownloadStream(<ObjectId>);
The output is the following error -
error occurred in downloadreport TypeError: Cannot read property 'write' of null
at Object.query (C:\project\node_modules\mongodb\lib\core\wireprotocol\query.js:29:19)
at Server.query (C:\project\node_modules\mongodb\lib\core\topologies\server.js:639:16)
at FindOperation.execute (C:\project\node_modules\mongodb\lib\operations\find.js:24:12)
at C:\project\node_modules\mongodb\lib\operations\execute_operation.js:168:15
at Server.selectServer (C:\project\node_modules\mongodb\lib\core\topologies\server.js:827:3)
at Server.selectServer (C:\project\node_modules\mongodb\lib\topologies\topology_base.js:363:32)
at executeWithServerSelection (C:\project\node_modules\mongodb\lib\operations\execute_operation.js:150:12)
at executeOperation (C:\project\node_modules\mongodb\lib\operations\execute_operation.js:81:16)
at Cursor._initializeCursor (C:\project\node_modules\mongodb\lib\core\cursor.js:545:7)
at Cursor._initializeCursor (C:\project\node_modules\mongodb\lib\cursor.js:191:11)
at nextFunction (C:\project\node_modules\mongodb\lib\core\cursor.js:748:10)
at Cursor._next (C:\project\node_modules\mongodb\lib\core\cursor.js:202:5)
at nextObject (C:\project\node_modules\mongodb\lib\operations\common_functions.js:234:10)
at NextOperation.execute (C:\project\node_modules\mongodb\lib\operations\next.js:26:5)
at executeOperation (C:\project\node_modules\mongodb\lib\operations\execute_operation.js:83:26)
at Cursor.next (C:\project\node_modules\mongodb\lib\cursor.js:217:12)
C:\project\node_modules\mongodb\lib\utils.js:133
throw err;
does anyone know what is it that I'm doing wrong?
PS: I also want to download and save the data I receive in a pdf file (the data is pdf content already). How can I achieve this?

How to use "node_redis" in a phantomjs script?

I want make a phantomjs script that actuates as consumer process reading values from a redis server. I see that exists this client for node (https://github.com/NodeRedis/node_redis) and I connect, write and read without problem executing a node script.
var redis = require("redis"),
client = redis.createClient();
client.on("error", function (err) {
console.log("Error " + err);
});
client.set("string key", "string val", redis.print);
client.get("string key", redis.print);
But when I do the same with phantomjs I obtain this error:
ReferenceError: Can't find variable: process
phantomjs://platform/command.js:4
TypeError: undefined is not a constructor (evaluating 'util.inherits(assert.AssertionError, Error)')
phantomjs://platform/assert.js:161
TypeError: undefined is not a constructor (evaluating 'util.inherits(RedisError, Error)')
phantomjs://platform/redisError.js:17
TypeError: undefined is not a constructor (evaluating 'util.inherits(ReplyError, RedisError)')
phantomjs://platform/replyError.js:16
TypeError: undefined is not a constructor (evaluating 'util.inherits(ParserError, RedisError)')
phantomjs://platform/parserError.js:18
ReferenceError: Can't find variable: Buffer
phantomjs://platform/parser.js:22 in bufferAlloc
phantomjs://platform/parser.js:8
TypeError: undefined is not a constructor (evaluating 'util.inherits(AbortError, RedisError)')
phantomjs://platform/customErrors.js:43
Error: Cannot find module 'events'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
Is there any way to use this package with phantomjs?
PhantomJS is not compatible with node.js, you can't use this package in it.
Your best bet is to use some node.js bridge for PhantomJS, like https://github.com/amir20/phantomjs-node or https://github.com/baudehlo/node-phantom-simple and then use node_redis in that node.js script.

Resources