Example
Example copied to clipboard
Fix error in bus.worldTime.currentTime
Way to reproduce an error
- Enable execution of domain.time.start hook by switching
config.examples.bus
value totrue
-
node server.js
- There is a log message in a console that means something works not properly but without explicit error
20:40:18 W1 log undefined - undefined
originated from
https://github.com/metarhia/Example/blob/2435b8e643af3fc4a62fea1f3f20bdedc1e1d9c1/application/domain/time/start.js#L9
4. Check the whole time
value by adding console.debug(time);
line and restarting the server.
5. time
contains an Error: Invalid result type: Field "dst_from" not of expected type: string; Field "dst_until" not of expected type: string
that is returned error but not thrown exception. That's why it cannot be catched and actually happens during processing of successful remote service answer.
Resolving
Direct request to the remote service reveals that dst_from
and day until
might has null as a value.
{
abbreviation: 'CET',
client_ip: '176.36.183.159',
datetime: '2023-12-15T21:44:59.632338+01:00',
day_of_week: 5,
day_of_year: 349,
dst: false,
dst_from: null,
dst_offset: 0,
dst_until: null,
raw_offset: 3600,
timezone: 'Europe/Rome',
unixtime: 1702673099,
utc_datetime: '2023-12-15T20:44:59.632338+00:00',
utc_offset: '+01:00',
week_number: 50
}
Which wasn't expected by returning schema https://github.com/metarhia/Example/blob/2435b8e643af3fc4a62fea1f3f20bdedc1e1d9c1/application/bus/worldTime/currentTime.js#L19-L21
Expected test result after fix approval
20:44:59 W1 log Europe/Rome - 2023-12-15T21:44:59.632338+01:00