Skip to content

Commit

Permalink
perf(GoogleAuth): Improve Client Creation From Files/Streams Perf (#1856
Browse files Browse the repository at this point in the history
)
  • Loading branch information
danielbankhead authored Aug 30, 2024
1 parent a56b198 commit 85d9d6f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/auth/googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,15 +787,15 @@ export class GoogleAuth<T extends AuthClient = JSONClient> {
'Must pass in a stream containing the Google auth settings.'
);
}
let s = '';
const chunks: string[] = [];
inputStream
.setEncoding('utf8')
.on('error', reject)
.on('data', chunk => (s += chunk))
.on('data', chunk => chunks.push(chunk))
.on('end', () => {
try {
try {
const data = JSON.parse(s);
const data = JSON.parse(chunks.join(''));
const r = this._cacheClientFromJSON(data, options);
return resolve(r);
} catch (err) {
Expand Down

0 comments on commit 85d9d6f

Please sign in to comment.