umijs / umi

A framework in react community ✨
https://umijs.org
MIT License
15.4k stars 2.65k forks source link

[Bug] umi3, 开启SSR后,小内容是正常的,现在接口内容过多时,渲染失败 #12731

Closed 1089109 closed 1 month ago

1089109 commented 1 month ago

接口内容返回有37764,已经渲染失败了

content-length: 37764

umi版本

"umi": "3.4.25"

现在测试到的是,其它页面是正常打开的,只有内容过多时才会失败

渲染失败的地址

http://www.huangcy.com/course/chapter/detail?chapterId=151&courseId=82

成功的地址

http://www.huangcy.com/course/chapter/detail?chapterId=150&courseId=82

页面请求接口的地方

 现在控制台只输出5555 web

const CourseDetail = (props: CourseDetailProps) => { return

hello
}

CourseDetail.getInitialProps = (async ({ isServer, store, history }) => { if (!isServer) return; console.log(11111, 'web') ...... console.log(5555, 'web') const { data: currentChapter } = await getChapterDetail({ id: Number(chapterId), isServer }).catch(err => { console.log('errror ?', err ) }); console.log(4444, 'web') let detailData: Course.CourseRule | null = null if (success && data) { detailData = data; } let content = ''; // 章节内容 let headerLinks = ''; // 将li 改成a链接

console.log(1)
console.log(currentChapter, 'currentChapter')
console.log(2)
// 右侧的索引目录修改
if (currentChapter) {
  content = currentChapter.content;
  content = setContentHeader(currentChapter.content, currentChapter.headerContent);
  headerLinks = setHeaderLink(currentChapter.headerContent);
}
console.log(3)

// 右侧的最多浏览文章/最多评论文章...
const { data: newInfo } = await getMaxArticle({
  current: 1,
  pageSize: 20,
  isBrowse: true,
  isNewArticle: true,
  isComment: true,
  isServer,
});

const {
  newArticleList = [],
  browseList = [],
  commentList = [],
} = newInfo as Classify.ArticleMaxRule;

return Promise.resolve({
  detailData,
  global,
  currentChapter,
  content,
  headerLinks,
  chapterId,
  newArticleList,
  browseList,
  commentList,
})

}) as IGetInitialProps;

server.js

`const Koa = require('koa'); const compress = require('koa-compress'); const mount = require('koa-mount'); const { join, extname } = require('path'); const { parseCookie, parseNavLang } = require('./serverHelper'); const port = 8020; // 端口 const root = join(__dirname, 'dist');

const app = new Koa(); app.use( compress({ threshold: 1024, gzip: { flush: require('zlib').constants.Z_SYNC_FLUSH, }, deflate: { flush: require('zlib').constants.Z_SYNC_FLUSH, }, br: false, // 禁用br解决https gzip不生效加载缓慢问题 }), );

let render; app.use(async (ctx, next) => { /**

app.use(mount('/dist', require('koa-static')(root)));

app.listen(port, () => { console.log(SSR服务启动成功 http://localhost:${port} 真实接口在80上,由于csr需要代理api接口); });

module.exports = app.callback(); `

github-actions[bot] commented 1 month ago

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。