Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在 agent 中无法使用 createAnonymousContext 创建出完整的 ctx #3946

Closed
seekcx opened this issue Sep 23, 2019 · 2 comments
Closed

Comments

@seekcx
Copy link

seekcx commented Sep 23, 2019

What happens?

agent.js 中使用 app.createAnonymousContext 方法创建的 ctx 并不完整,没有 service 相关属性。

Mini Showcase Repository(REQUIRED)

// agent.js
'use strict';

module.exports = app => {
  const ctx = app.createAnonymousContext();
  console.log(ctx.service); // undefined
};

How To Reproduce

Steps to reproduce the behavior:

  1. 创建 agent.js
  2. app.createAnonymousContext();
  3. 访问 ctx 的 service

Expected behavior

  1. 能够正确访问 service

Context

  • Node Version: v10.14.1
  • Egg Version: v2.15.1
  • Platform: osx
@atian25
Copy link
Member

atian25 commented Oct 10, 2019

@svenjia
Copy link

svenjia commented Apr 11, 2024

@atian25 请问一下,多进程模式下,我启动时没法在agent中调用service进行数据插入,但是在app.js中调用service导致同时多个worker同时写入,数据库会报错~比如主键重复,写死锁。我又不想用事务,也不想指定workers=1,请问有什么方法吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants