protocolbuffers / protocolbuffers/protobuf-javascript
BUG: Timestamp.toObject() returning zeroed value
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 471
- Forks
- 91
- Avg merge
- 3h 57m
- Merged PRs (30d)
- 2
Description
In the latest version, 3.21.4, the Timestamp.toObject() function isn't working correctly.
Previously it would return the timestamp as an object with keys for seconds and milliseconds. However now it is returning zero values for both.
This is a function where I noticed the issue, I've added some logging which pointed out toObject() as being the problem.
function dateToTs(date: Date): Timestamp {
const ts = new Timestamp();
ts.fromDate(date);
console.log(
"date:",
date,
"timestamp:",
ts.getSeconds(),
ts.getNanos(),
ts.toObject(),
);
return ts;
}
See the screenshot below for the resulting console log, where you can see the seconds and milliseconds are set, but the toObject return is zeroed
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Timestamp.toObject() and compare its result with getSeconds() and getNanos() when the value is created through fromDate(), using the dateToTs() example from the report. Reproduce the zeroed fields on version 3.21.4; done when toObject() returns the populated seconds and milliseconds values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100