Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The same code what send sse work with bun dev and not work with bun -b dev #16043

Open
Maxttier opened this issue Dec 29, 2024 · 0 comments
Open
Labels
bug Something isn't working needs triage

Comments

@Maxttier
Copy link

Maxttier commented Dec 29, 2024

What version of Bun is running?

latest

What platform is your computer?

linux

What steps can reproduce the bug?

unjs/h3#940

With unjs/h3 server

Work without call of stream.write() if run with bun dev not work if run with bun -b dev. To work need to add stream.write().

const sse = require('https://github.com/EventSource/node-ssestream/blob/master/index.ts');
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");



const stream = new sse.SseStream(request);
stream.pipe(response, options);

// stream.write('');

const subscription = result
    .pipe((0, operators_1.map)((message) => {
    if ((0, shared_utils_1.isObject)(message)) {
        return message;
    }
    return { data: message };
}), (0, operators_1.concatMap)(message => 
    new Promise(resolve => stream.writeMessage(
        message, 
        () => resolve()))), 
        (0, operators_1.catchError
    )(err => {
    const data = err instanceof Error ? err.message : err;
    stream.writeMessage({ type: 'error', data }, writeError => {
        if (writeError) {
            this.logger.error(writeError);
        }
    });
    return rxjs_1.EMPTY;
}))
    .subscribe({
    complete: () => {
        response.end();
    },
});

request.on('close', () => {
    subscription.unsubscribe();
    if (!stream.writableEnded) {
        stream.end();
    }
});

What is the expected behavior?

200 ok

What do you see instead?

204 no content

Additional information

No response

@Maxttier Maxttier added bug Something isn't working needs triage labels Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant