Closed bluepuma77 closed 3 months ago
Hello @bluepuma77 ,
emit()
doesn't throw errors, it returns Unsafe<void>
, which is an Either<L,R> in disguise, in this case L
being void
and R
an Error
.
import { produce } from 'sveltekit-sse';
export function POST() {
return produce(async function start({ emit }) {
while (true) {
const { error } = await emit('event', { some: 'data' });
if (error) {
console.error(`There's been an error.\n${error.message}`);
return;
}
}
});
}
When it comes to static analysis, I'm getting a type error as expected -
Let me know if this solves your issue.
I'm closing this issue due to inactivity. Feel free to open another issue or follow up here if you think it should be reopened.
When using
emit('event', { some: 'data' })
, it seems nothing is sent to the client, and no error message is shown or thrown.It would be great if a notice would be provided to the developer that they use wrong parameter format.