Error when trying Websocket Server with HTTP callback

Everything seems to be set up and working properly except when I run the Websocket server with persist using this env:

CALLBACK_URL=http://localhost:3001/ CALLBACK_OBJECTS='{"content":"Y.Map"}' PORT=1234 YPERSISTENCE=./dbDir node ./node_modules/y-websocket/bin/server.js

I get this error:

TypeError: getContent(...).toJSON is not a function

And this is how my doc looks:

const ydoc = new Y.Doc();
const ymap = ydoc.getMap('content');
ymap.set('doc', myJson);

Otherwise, without the CALLBACK_OBJECTS set, the http request is received as expect, it just contains no body.

Also, @dmonad, thank you for the support you’re providing. I don’t know how you have time to reply as fast as you do, but I appreciate it.

It should be CALLBACK_OBJECTS='{"content":"Map"}. It would be useful to throw an error when the specified type-name doesn’t exist.

Thanks for showing appreciation :slight_smile:
Thanks to my sponsors I can focus more on Yjs and providing support for everyone.

1 Like

This fixed the error, but I’m not seeing the data in the req body. I assume that’s where it would be.

^ Ignore that, I just forgot to add json parser to Express.

I’ll leave this question/request though:
Also, is there a way to send additional information like maybe the params set on the provider?

I think you can just specify CALLBACK_URL=http://localhost:3001?param=true. because the content is sent in the body.

1 Like