diff --git a/packages/components/src/components/Log/Log.jsx b/packages/components/src/components/Log/Log.jsx index c99f3315a..9d3eeabf3 100644 --- a/packages/components/src/components/Log/Log.jsx +++ b/packages/components/src/components/Log/Log.jsx @@ -1,5 +1,5 @@ /* -Copyright 2019-2025 The Tekton Authors +Copyright 2019-2026 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -422,6 +422,8 @@ export class LogContainer extends Component { loadLog = async () => { // In development mode this request is duplicated due to usage of StrictMode component wrapper // It highlights a potential problem but only affects local dev and not production mode + this.cancelled = false; + const { fetchLogs, forcePolling, intl, stepStatus, pollingInterval } = this.props; if (!fetchLogs) { diff --git a/src/utils/index.js b/src/utils/index.js index a396aa5f7..b17da1fe7 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -155,8 +155,8 @@ export function getLogsRetriever({ return ({ stepName, stepStatus, taskRun }) => fetchLogs({ stepName, - stream: isLogStreamingEnabled, stepStatus, + stream: isLogStreamingEnabled, taskRun }).catch(() => { onFallback(true); @@ -165,7 +165,8 @@ export function getLogsRetriever({ }); } - return fetchLogs; + return ({ stepName, stepStatus, taskRun }) => + fetchLogs({ stepName, stepStatus, stream: isLogStreamingEnabled, taskRun }); } // K8s label documentation comes from here: diff --git a/src/utils/index.test.js b/src/utils/index.test.js index 14cfb37a6..badf32613 100644 --- a/src/utils/index.test.js +++ b/src/utils/index.test.js @@ -266,6 +266,19 @@ describe('getLogsRetriever', () => { }); }); + it('should handle default logs retriever with streaming enabled', () => { + vi.spyOn(API, 'getPodLog').mockImplementation(() => {}); + const logsRetriever = getLogsRetriever({ isLogStreamingEnabled: true }); + expect(logsRetriever).toBeDefined(); + logsRetriever({ stepName, stepStatus, taskRun }); + expect(API.getPodLog).toHaveBeenCalledWith({ + container: stepName, + name: podName, + namespace, + stream: true + }); + }); + it('should handle default logs retriever with external fallback enabled', async () => { const externalLogsURL = 'fake_externalLogsURL'; vi.spyOn(API, 'getPodLog').mockImplementation(() => {});