0.18.5+ is breaking return structure of client.request
vieira opened this issue · comments
I am implementing a nodejs library that consumes the REST API for Google Cloud PubSub.
In version 0.18.4 the following example invocation:
this.client.request({
body: { messages },
method: 'POST',
uri: `topics/${this.name}:publish`,
json: true,
})
would return as expected:
{ messageIds: [ '104101137976802' ] }
Since version 0.18.5 and up to the latest 0.18.9, the same call now returns
IncomingMessage {
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: true,
endEmitted: true,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
_events:
{ end: [ [Function: responseOnEnd], [Function] ],
close: [Function] },
_eventsCount: 2,
_maxListeners: undefined,
socket:
TLSSocket {
_tlsOptions:
{ pipe: false,
secureContext: [SecureContext],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: <Buffer 30 82 05 7f 02 01 01 02 02 03 03 04 02 c0 2b 04 20 01 a6 e0 64 de 31 d7 cb 2b 89 c5 39 d5 8c 11 4e 68 1e ee a5 e6 5d c7 c8 80 95 48 ab d6 ea bc 54 04 ... >,
NPNProtocols: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'pubsub.googleapis.com',
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events:
{ close: [Array],
finish: [Function: onSocketFinish],
end: [Function: onReadableStreamEnd],
secure: [Function: onConnectSecure],
free: [Function: onFree],
agentRemove: [Function: onRemove],
drain: [Function: ondrain],
error: [Function] },
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
_parent: null,
_host: 'pubsub.googleapis.com',
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [BufferList],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: true,
_bytesDispatched: 534,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
allowHalfOpen: false,
server: undefined,
_server: null,
ssl:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 11314,
_destroyed: false,
[Symbol(res)]:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
[Symbol(asyncId)]: -1,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(bytesRead)]: 0,
[Symbol(connect-options)]:
{ rejectUnauthorized: true,
ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
checkServerIdentity: [Function: checkServerIdentity],
minDHSize: 1024,
servername: 'pubsub.googleapis.com',
keepAlive: true,
_defaultAgent: [Agent],
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
gzip: true,
forever: true,
pool: [Object],
body: '{"messages":[{"data":"eyJ0ZXh0IjoidGhpcyBpcyBhIHRlc3QifQ=="}]}',
method: 'POST',
uri: [Url],
headers: [Object],
callback: [Function],
readable: true,
writable: true,
explicitMethod: true,
_qs: [Querystring],
_auth: [Auth],
_oauth: [OAuth],
_multipart: [Multipart],
_redirect: [Redirect],
_tunnel: [Tunnel],
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
dests: [],
__isRequestRequest: true,
_callback: [Function: onResponse],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_disableCookies: true,
_jar: undefined,
port: 443,
host: 'pubsub.googleapis.com',
path: null,
_json: true,
httpModule: [Object],
agentClass: [Function],
agentOptions: [Object],
agent: [Agent],
_started: true,
href: 'https://pubsub.googleapis.com/v1/projects/<redacted>/topics/test-queue:publish',
_agentKey: 'pubsub.googleapis.com:443::::::::::::::::',
encoding: null,
session: <Buffer 30 82 05 7f 02 01 01 02 02 03 03 04 02 c0 2b 04 20 01 a6 e0 64 de 31 d7 cb 2b 89 c5 39 d5 8c 11 4e 68 1e ee a5 e6 5d c7 c8 80 95 48 ab d6 ea bc 54 04 ... > },
[Symbol(asyncId)]: 103,
[Symbol(triggerAsyncId)]: 101 },
connection:
TLSSocket {
_tlsOptions:
{ pipe: false,
secureContext: [SecureContext],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: <Buffer 30 82 05 7f 02 01 01 02 02 03 03 04 02 c0 2b 04 20 01 a6 e0 64 de 31 d7 cb 2b 89 c5 39 d5 8c 11 4e 68 1e ee a5 e6 5d c7 c8 80 95 48 ab d6 ea bc 54 04 ... >,
NPNProtocols: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'pubsub.googleapis.com',
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events:
{ close: [Array],
finish: [Function: onSocketFinish],
end: [Function: onReadableStreamEnd],
secure: [Function: onConnectSecure],
free: [Function: onFree],
agentRemove: [Function: onRemove],
drain: [Function: ondrain],
error: [Function] },
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
_parent: null,
_host: 'pubsub.googleapis.com',
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [BufferList],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: true,
_bytesDispatched: 534,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
allowHalfOpen: false,
server: undefined,
_server: null,
ssl:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 11314,
_destroyed: false,
[Symbol(res)]:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
[Symbol(asyncId)]: -1,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(bytesRead)]: 0,
[Symbol(connect-options)]:
{ rejectUnauthorized: true,
ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
checkServerIdentity: [Function: checkServerIdentity],
minDHSize: 1024,
servername: 'pubsub.googleapis.com',
keepAlive: true,
_defaultAgent: [Agent],
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
gzip: true,
forever: true,
pool: [Object],
body: '{"messages":[{"data":"eyJ0ZXh0IjoidGhpcyBpcyBhIHRlc3QifQ=="}]}',
method: 'POST',
uri: [Url],
headers: [Object],
callback: [Function],
readable: true,
writable: true,
explicitMethod: true,
_qs: [Querystring],
_auth: [Auth],
_oauth: [OAuth],
_multipart: [Multipart],
_redirect: [Redirect],
_tunnel: [Tunnel],
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
dests: [],
__isRequestRequest: true,
_callback: [Function: onResponse],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_disableCookies: true,
_jar: undefined,
port: 443,
host: 'pubsub.googleapis.com',
path: null,
_json: true,
httpModule: [Object],
agentClass: [Function],
agentOptions: [Object],
agent: [Agent],
_started: true,
href: 'https://pubsub.googleapis.com/v1/projects/<redacted>/topics/test-queue:publish',
_agentKey: 'pubsub.googleapis.com:443::::::::::::::::',
encoding: null,
session: <Buffer 30 82 05 7f 02 01 01 02 02 03 03 04 02 c0 2b 04 20 01 a6 e0 64 de 31 d7 cb 2b 89 c5 39 d5 8c 11 4e 68 1e ee a5 e6 5d c7 c8 80 95 48 ab d6 ea bc 54 04 ... > },
[Symbol(asyncId)]: 103,
[Symbol(triggerAsyncId)]: 101 },
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers:
{ 'content-type': 'application/json; charset=UTF-8',
vary: 'Origin, X-Origin, Referer',
'content-encoding': 'gzip',
date: 'Fri, 25 May 2018 00:17:49 GMT',
server: 'ESF',
'cache-control': 'private',
'x-xss-protection': '1; mode=block',
'x-frame-options': 'SAMEORIGIN',
'x-content-type-options': 'nosniff',
'alt-svc': 'hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35"',
'transfer-encoding': 'chunked' },
rawHeaders:
[ 'Content-Type',
'application/json; charset=UTF-8',
'Vary',
'Origin',
'Vary',
'X-Origin',
'Vary',
'Referer',
'Content-Encoding',
'gzip',
'Date',
'Fri, 25 May 2018 00:17:49 GMT',
'Server',
'ESF',
'Cache-Control',
'private',
'X-XSS-Protection',
'1; mode=block',
'X-Frame-Options',
'SAMEORIGIN',
'X-Content-Type-Options',
'nosniff',
'Alt-Svc',
'hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35"',
'Transfer-Encoding',
'chunked' ],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 200,
statusMessage: 'OK',
client:
TLSSocket {
_tlsOptions:
{ pipe: false,
secureContext: [SecureContext],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: <Buffer 30 82 05 7f 02 01 01 02 02 03 03 04 02 c0 2b 04 20 01 a6 e0 64 de 31 d7 cb 2b 89 c5 39 d5 8c 11 4e 68 1e ee a5 e6 5d c7 c8 80 95 48 ab d6 ea bc 54 04 ... >,
NPNProtocols: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'pubsub.googleapis.com',
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events:
{ close: [Array],
finish: [Function: onSocketFinish],
end: [Function: onReadableStreamEnd],
secure: [Function: onConnectSecure],
free: [Function: onFree],
agentRemove: [Function: onRemove],
drain: [Function: ondrain],
error: [Function] },
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
_parent: null,
_host: 'pubsub.googleapis.com',
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [BufferList],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: true,
_bytesDispatched: 534,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
allowHalfOpen: false,
server: undefined,
_server: null,
ssl:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 11314,
_destroyed: false,
[Symbol(res)]:
TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
owner: [Circular],
onread: [Function: onread],
onhandshakestart: [Function: noop],
onhandshakedone: [Function: bound ],
onocspresponse: [Function: onocspresponse],
onerror: [Function: onerror] },
[Symbol(asyncId)]: -1,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(bytesRead)]: 0,
[Symbol(connect-options)]:
{ rejectUnauthorized: true,
ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
checkServerIdentity: [Function: checkServerIdentity],
minDHSize: 1024,
servername: 'pubsub.googleapis.com',
keepAlive: true,
_defaultAgent: [Agent],
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
gzip: true,
forever: true,
pool: [Object],
body: '{"messages":[{"data":"eyJ0ZXh0IjoidGhpcyBpcyBhIHRlc3QifQ=="}]}',
method: 'POST',
uri: [Url],
headers: [Object],
callback: [Function],
readable: true,
writable: true,
explicitMethod: true,
_qs: [Querystring],
_auth: [Auth],
_oauth: [OAuth],
_multipart: [Multipart],
_redirect: [Redirect],
_tunnel: [Tunnel],
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
dests: [],
__isRequestRequest: true,
_callback: [Function: onResponse],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_disableCookies: true,
_jar: undefined,
port: 443,
host: 'pubsub.googleapis.com',
path: null,
_json: true,
httpModule: [Object],
agentClass: [Function],
agentOptions: [Object],
agent: [Agent],
_started: true,
href: 'https://pubsub.googleapis.com/v1/projects/<redacted>/topics/test-queue:publish',
_agentKey: 'pubsub.googleapis.com:443::::::::::::::::',
encoding: null,
session: <Buffer 30 82 05 7f 02 01 01 02 02 03 03 04 02 c0 2b 04 20 01 a6 e0 64 de 31 d7 cb 2b 89 c5 39 d5 8c 11 4e 68 1e ee a5 e6 5d c7 c8 80 95 48 ab d6 ea bc 54 04 ... > },
[Symbol(asyncId)]: 103,
[Symbol(triggerAsyncId)]: 101 },
_consuming: true,
_dumped: false,
req:
ClientRequest {
_events:
{ socket: [Function],
response: [Function: bound ],
error: [Array],
drain: [Function],
timeout: [Function],
prefinish: [Function: requestOnPrefinish] },
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: false,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'pubsub.googleapis.com',
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle: [TLSWrap],
_parent: null,
_host: 'pubsub.googleapis.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
_bytesDispatched: 534,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
allowHalfOpen: false,
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 11314,
_destroyed: false,
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: -1,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(bytesRead)]: 0,
[Symbol(connect-options)]: [Object],
[Symbol(asyncId)]: 103,
[Symbol(triggerAsyncId)]: 101 },
connection:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'pubsub.googleapis.com',
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle: [TLSWrap],
_parent: null,
_host: 'pubsub.googleapis.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
_bytesDispatched: 534,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
allowHalfOpen: false,
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: null,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 11314,
_destroyed: false,
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: -1,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(bytesRead)]: 0,
[Symbol(connect-options)]: [Object],
[Symbol(asyncId)]: 103,
[Symbol(triggerAsyncId)]: 101 },
_header: 'POST /v1/projects/<redacted>/topics/test-queue:publish HTTP/1.1\r\nUser-Agent: @guuru-queue-srv/1.0.0\r\nx-goog-api-client: gl-node/9.11.1 gccl/1.0.0\r\nAuthorization: Bearer <redacted>\r\nhost: pubsub.googleapis.com\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\ncontent-type: application/json\r\ncontent-length: 62\r\nConnection: keep-alive\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent:
Agent {
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: {},
freeSockets: [Object],
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object] },
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/v1/projects/<redacted>/topics/test-queue:publish',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(isCorked)]: false,
[Symbol(outHeadersKey)]:
{ 'user-agent': [Array],
'x-goog-api-client': [Array],
authorization: [Array],
host: [Array],
'accept-encoding': [Array],
accept: [Array],
'content-type': [Array],
'content-length': [Array] } },
request:
Request {
_events:
{ error: [Function: bound ],
complete: [Function: bound ],
pipe: [Function],
data: [Function],
end: [Function] },
_eventsCount: 5,
_maxListeners: undefined,
timeout: 60000,
gzip: true,
forever: true,
pool: { maxSockets: Infinity, 'https:': [Agent] },
body: '{"messages":[{"data":"eyJ0ZXh0IjoidGhpcyBpcyBhIHRlc3QifQ=="}]}',
method: 'POST',
uri:
Url {
protocol: 'https:',
slashes: true,
auth: null,
host: 'pubsub.googleapis.com',
port: 443,
hostname: 'pubsub.googleapis.com',
hash: null,
search: null,
query: null,
pathname: '/v1/projects/<redacted>/topics/test-queue:publish',
path: '/v1/projects/<redacted>/topics/test-queue:publish',
href: 'https://pubsub.googleapis.com/v1/projects/<redacted>/topics/test-queue:publish' },
headers:
{ 'User-Agent': '@guuru-queue-srv/1.0.0',
'x-goog-api-client': 'gl-node/9.11.1 gccl/1.0.0',
Authorization: 'Bearer <redacted>',
'accept-encoding': 'gzip, deflate',
accept: 'application/json',
'content-type': 'application/json',
'content-length': 62 },
callback: [Function],
readable: true,
writable: true,
explicitMethod: true,
_qs:
Querystring {
request: [Circular],
lib: [Object],
useQuerystring: undefined,
parseOptions: {},
stringifyOptions: {} },
_auth:
Auth {
request: [Circular],
hasAuth: false,
sentAuth: false,
bearerToken: null,
user: null,
pass: null },
_oauth: OAuth { request: [Circular], params: null },
_multipart:
Multipart {
request: [Circular],
boundary: 'da4f31be-d9af-4dcd-814c-0e20834f18af',
chunked: false,
body: null },
_redirect:
Redirect {
request: [Circular],
followRedirect: true,
followRedirects: true,
followAllRedirects: false,
followOriginalHttpMethod: false,
allowRedirect: [Function],
maxRedirects: 10,
redirects: [],
redirectsFollowed: 0,
removeRefererHeader: false },
_tunnel:
Tunnel {
request: [Circular],
proxyHeaderWhiteList: [Array],
proxyHeaderExclusiveList: [] },
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
dests: [],
__isRequestRequest: true,
_callback: [Function: onResponse],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_disableCookies: true,
_jar: undefined,
port: 443,
host: 'pubsub.googleapis.com',
path: '/v1/projects/<redacted>/topics/test-queue:publish',
_json: true,
httpModule:
{ Agent: [Function],
globalAgent: [Agent],
Server: [Function],
createServer: [Function: createServer],
get: [Function: get],
request: [Function: request] },
agentClass: { [Function: Agent] super_: [Function] },
agentOptions: { keepAlive: true },
agent:
Agent {
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: {},
freeSockets: [Object],
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object] },
_started: true,
href: 'https://pubsub.googleapis.com/v1/projects/<redacted>/topics/test-queue:publish',
req:
ClientRequest {
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: false,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
connection: [TLSSocket],
_header: 'POST /v1/projects/<redacted>/topics/test-queue:publish HTTP/1.1\r\nUser-Agent: @guuru-queue-srv/1.0.0\r\nx-goog-api-client: gl-node/9.11.1 gccl/1.0.0\r\nAuthorization: Bearer <redacted>\r\nhost: pubsub.googleapis.com\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\ncontent-type: application/json\r\ncontent-length: 62\r\nConnection: keep-alive\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/v1/projects/<redacted>/topics/test-queue:publish',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(isCorked)]: false,
[Symbol(outHeadersKey)]: [Object] },
ntick: true,
timeoutTimer: null,
response: [Circular],
originalHost: 'pubsub.googleapis.com',
originalHostHeaderName: 'host',
responseContent:
Gunzip {
_readableState: [ReadableState],
readable: false,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: true,
_transformState: [Object],
bytesRead: 64,
_handle: null,
_hadError: false,
_writeState: [Uint32Array],
_outBuffer: <Buffer 7b 0a 20 20 22 6d 65 73 73 61 67 65 49 64 73 22 3a 20 5b 0a 20 20 20 20 22 31 30 34 31 30 30 31 38 30 34 35 37 30 35 35 22 0a 20 20 5d 0a 7d 0a 03 00 ... >,
_outOffset: 48,
_level: -1,
_strategy: 0,
_chunkSize: 16384,
_flushFlag: 2,
_scheduledFlushFlag: 0,
_origFlushFlag: 2,
_finishFlushFlag: 2,
_info: undefined },
_ended: true,
_destdata: true,
_callbackCalled: true },
toJSON: [Function: responseToJSON],
caseless:
Caseless {
dict:
{ 'content-type': 'application/json; charset=UTF-8',
vary: 'Origin, X-Origin, Referer',
'content-encoding': 'gzip',
date: 'Fri, 25 May 2018 00:17:49 GMT',
server: 'ESF',
'cache-control': 'private',
'x-xss-protection': '1; mode=block',
'x-frame-options': 'SAMEORIGIN',
'x-content-type-options': 'nosniff',
As of 0.18, request
returns Promise<request.Response>
(via explicit TypeScript definition) rather than Promise<RequestBodyType>
(implicit via promisification). I know in practice this wasn't observable in 0.18.4 but you should treat >=0.18 <0.18.5
as buggy -- in these versions the behavior didn't match the TypeScript definition.
I would recommend upgrading to 0.18.9 and using the body
field to get the original body. As the TypeScript definition is now an explicit contract I don't expect the behavior to change anymore.