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

streams: fix util inspect returning undefined for CompressionStream & DecompressionStream #52283

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/webstreams/compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CompressionStream {
}

[kInspect](depth, options) {
customInspect(depth, options, 'CompressionStream', {
return customInspect(depth, options, 'CompressionStream', {
readable: this.#transform.readable,
writable: this.#transform.writable,
});
Expand Down Expand Up @@ -128,7 +128,7 @@ class DecompressionStream {
}

[kInspect](depth, options) {
customInspect(depth, options, 'DecompressionStream', {
return customInspect(depth, options, 'DecompressionStream', {
readable: this.#transform.readable,
writable: this.#transform.writable,
});
Expand Down
41 changes: 41 additions & 0 deletions test/parallel/test-compression-decompression-stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Flags: --no-warnings --expose-internals
'use strict';

require('../common');

const assert = require('assert');
mertcanaltin marked this conversation as resolved.
Show resolved Hide resolved
const { describe, it } = require('node:test');
const {
CompressionStream,
DecompressionStream,
} = require('stream/web');
mertcanaltin marked this conversation as resolved.
Show resolved Hide resolved

const {
customInspectSymbol: kInspect,
} = require('internal/util');

describe('DecompressionStream kInspect method', () => {
it('should return a predictable inspection string with DecompressionStream', () => {
const decompressionStream = new DecompressionStream('deflate');
const depth = 1;
const options = {};
const actual = decompressionStream[kInspect](depth, options);

assert(actual.includes('DecompressionStream'));
assert(actual.includes('ReadableStream'));
assert(actual.includes('WritableStream'));
});
});

describe('CompressionStream kInspect method', () => {
it('should return a predictable inspection string with CompressionStream', () => {
const compressionStream = new CompressionStream('deflate');
const depth = 1;
const options = {};
const actual = compressionStream[kInspect](depth, options);

assert(actual.includes('CompressionStream'));
assert(actual.includes('ReadableStream'));
assert(actual.includes('WritableStream'));
});
});
Loading