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
5 changes: 5 additions & 0 deletions .changeset/quiet-logs-poll-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Show API status and error details when app log polling fails during `shopify app dev`.
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,29 @@ describe('pollAppLogs', () => {
})

// Then
expect(outputWarnSpy).toHaveBeenCalledWith('Error while polling app logs.', stdout)
expect(outputWarnSpy).toHaveBeenCalledWith('Error while polling app logs (HTTP 500): errorMessage.', stdout)
expect(vi.getTimerCount()).toEqual(1)
})

test('displays the API error when app log polling fails', async () => {
const outputWarnSpy = vi.spyOn(output, 'outputWarn')
const response = {errors: ['Malformed JWT'], status: 400}
const mockedDeveloperPlatformClient = testDeveloperPlatformClient({
appLogs: vi.fn().mockResolvedValue(response),
})

await pollAppLogs({
stdout,
appLogsFetchInput: {jwtToken: JWT_TOKEN},
developerPlatformClient: mockedDeveloperPlatformClient,
resubscribeCallback: MOCKED_RESUBSCRIBE_CALLBACK,
storeName: 'storeName',
organizationId: 'organizationId',
logsDir: TEST_LOGS_DIR,
})

expect(outputWarnSpy).toHaveBeenCalledWith('Error while polling app logs (HTTP 400): Malformed JWT.', stdout)
expect(outputWarnSpy).toHaveBeenCalledWith('Retrying in 5 seconds.', stdout)
expect(vi.getTimerCount()).toEqual(1)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const pollAppLogs = async ({
outputWarn(`Retrying in ${retryIntervalMs / 1000} seconds.`, stdout)
},
onUnknownError: (retryIntervalMs) => {
outputWarn(`Error while polling app logs.`, stdout)
outputWarn(`Error while polling app logs (HTTP ${status}): ${errors.join(', ')}.`, stdout)
outputWarn(`Retrying in ${retryIntervalMs / 1000} seconds.`, stdout)
},
onResubscribe: () => {
Expand Down
Loading