You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe the library tried to call a non-existant function.
Code snippet
import { env } from '$env/dynamic/private';
import { fail, type RequestEvent } from '@sveltejs/kit';
import { produce } from 'sveltekit-sse';
// ---------- not important in regards to the problem, just for context ----------
function delay(milliseconds: number) {
return new Promise(function run(resolve) {
setTimeout(resolve, milliseconds);
});
}
async function getImg() {
try {
const url = env.IMAGE_URL;
const response = await fetch(url as string);
const json = await response.json();
if (json.image) return json.image;
} catch (err) {
return null;
}
}
async function testImgAcessibility() {
const img = await getImg();
if (img) return true;
return false;
}
export async function POST(event: RequestEvent) {
if (!event.locals.session) {
return fail(400);
}
const imgAcessible = await testImgAcessibility();
console.log('able to fetch image:', imgAcessible);
// ---------- ---------- the important part ---------- ----------
return produce(
async function start({ emit }) {
console.log(
'started streaming to:',
event.locals.user!.type,
'(session id: ' + event.locals.session!.id + ')'
);
while (true) {
const img = await getImg();
if (img) {
const { error } = emit('message', img);
if (error) {
console.log('error in emit:', error);
return;
}
await delay(16);
} else {
const { error } = emit('error', 'nullimg');
if (error) {
console.log('error in emit:', error);
return;
}
await delay(1000);
}
}
},
{
stop() {
console.log('stopped streaming to:', event.locals.user!.type);
}
}
);
}
Error
started streaming to: student (session id: yt7ea335sffwpiwkxvt4stuyamftibpoc35dhrp3)
/home/kuba/Documents/Code/hackathon/node_modules/sveltekit-sse/dist/produce.js:105
await cancelInline(self)
^
TypeError: cancelInline is not a function
at stopLocal (/home/kuba/Documents/Code/hackathon/node_modules/sveltekit-sse/dist/produce.js:105:17)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Array.run (/home/kuba/Documents/Code/hackathon/node_modules/sveltekit-sse/dist/produce.js:112:13)
Node.js v22.11.0
The text was updated successfully, but these errors were encountered:
razshare
added
the
seen
I've seen and read this issue and I'll try find some time soon to work on it.
label
Dec 13, 2024
Problem
I believe the library tried to call a non-existant function.
Code snippet
Error
The text was updated successfully, but these errors were encountered: