Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 18 additions & 10 deletions src/endpoint/s3/s3_rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,16 @@ function handle_error(req, res, err) {
duration_ms: req.start_time ? Date.now() - req.start_time : undefined,
});
}
dbg.error('S3 ERROR', reply,
req.method, req.originalUrl,
JSON.stringify(req.headers),
err.stack || err,
err.context ? `- context: ${err.context?.trim()}` : '',
);
if (s3err.code === 'NoSuchKey' && (req.method === 'GET' || req.method === 'HEAD')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to include NO_SUCH_OBJECT also?

dbg.log1('S3 NoSuchKey', req.method, req.originalUrl, req.request_id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add JSON.stringify(req.headers) too?

} else {
dbg.error('S3 ERROR', reply,
req.method, req.originalUrl,
JSON.stringify(req.headers),
err.stack || err,
err.context ? `- context: ${err.context?.trim()}` : '',
);
}
if (res.headersSent) {
dbg.log0('Sending error xml in body, but too late for headers...');
} else {
Expand All @@ -599,10 +603,14 @@ async function _handle_html_response(req, res, err) {
</body> \
</html>`;
res.statusCode = s3err.http_code;
dbg.error('S3 ERROR', reply,
req.method, req.originalUrl,
JSON.stringify(req.headers),
err.stack || err);
if (s3err.code === 'NoSuchKey' && (req.method === 'GET' || req.method === 'HEAD')) {
dbg.log1('S3 NoSuchKey', req.method, req.originalUrl, req.request_id);
} else {
dbg.error('S3 ERROR', reply,
req.method, req.originalUrl,
JSON.stringify(req.headers),
err.stack || err);
}
res.setHeader('Content-Type', 'text/html');
res.setHeader('Content-Length', Buffer.byteLength(reply));
res.end(reply);
Expand Down
24 changes: 17 additions & 7 deletions src/rpc/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,17 @@ class RPC extends EventEmitter {
this._request_logger('RPC REQUEST CATCH', req.srv, '==>', err);
}

dbg.error('RPC._request: response ERROR',
req.base_info,
'params', util.inspect(params, true, null, true),
req.took_info,
err.stack || err
);
// Expected missing-object outcomes (maps to S3 NoSuchKey) — quiet log, no stack/params dump
if (err.rpc_code === 'NO_SUCH_OBJECT') {
dbg.log1('RPC._request: NO_SUCH_OBJECT', req.base_info, req.took_info);
} else {
dbg.error('RPC._request: response ERROR',
req.base_info,
'params', util.inspect(params, true, null, true),
req.took_info,
err.stack || err
);
}

if (this.should_emit_request_errors) {
this.emit('request_error', err);
Expand Down Expand Up @@ -359,7 +364,12 @@ class RPC extends EventEmitter {
await this._send_response(conn, req);

} catch (err) {
console.error('RPC._on_request: ERROR', req.base_info, err.stack || err);
// Expected missing-object outcomes (maps to S3 NoSuchKey) — quiet log, no stack
if (err.rpc_code === 'NO_SUCH_OBJECT') {
dbg.log1('RPC._on_request: NO_SUCH_OBJECT', req.base_info);
} else {
console.error('RPC._on_request: ERROR', req.base_info, err.stack || err);
}
// propagate rpc errors from inner rpc client calls (using err.rpc_code)
// set default internal error if no other error was specified
if (err instanceof RpcError) {
Expand Down
Loading